diff --git a/api-specifications/properties.json b/api-specifications/properties.json index 39dfabae..3b243b5d 100644 --- a/api-specifications/properties.json +++ b/api-specifications/properties.json @@ -10,6 +10,152 @@ }, "entries": {}, "definitions": { + "Background": { + "kind": "object", + "entries": { + "colorType": { + "description": "How the font color is defined, defaults to colorPicker", + "optional": true, + "kind": "union", + "items": [ + { + "kind": "literal", + "value": "'auto'" + }, + { + "kind": "literal", + "value": "'colorPicker'" + }, + { + "kind": "literal", + "value": "'byExpression'" + } + ], + "type": "string" + }, + "color": { + "description": "Color defined by index or hex code, needed if colorType is colorPicker", + "optional": true, + "type": "#/definitions/PaletteColor" + }, + "colorExpression": { + "description": "Color defined by expression, needed if colorType is byExpression", + "optional": true, + "type": "#/definitions/ColorExpression" + } + } + }, + "Border": { + "kind": "object", + "entries": { + "top": { + "description": "Set to true to show thicker top border, default is true", + "optional": true, + "type": "boolean" + }, + "fullBorder": { + "description": "Set to true to show full border, default is true", + "optional": true, + "type": "boolean" + }, + "colorType": { + "description": "How the border color is defined, defaults to auto", + "optional": true, + "kind": "union", + "items": [ + { + "kind": "literal", + "value": "'auto'" + }, + { + "kind": "literal", + "value": "'colorPicker'" + }, + { + "kind": "literal", + "value": "'byExpression'" + } + ], + "type": "string" + }, + "color": { + "description": "Color defined by index or hex code, needed if colorType is colorPicker", + "optional": true, + "type": "#/definitions/PaletteColor" + }, + "colorExpression": { + "description": "Color defined by expression, needed if colorType is byExpression", + "optional": true, + "type": "#/definitions/ColorExpression" + } + } + }, + "ColorExpression": { + "description": "Format for using color expressions", + "kind": "object", + "entries": { + "qStringExpression": { + "kind": "object", + "entries": { + "qExpr": { + "description": "expression that resolves to a supported color format", + "type": "string" + } + } + } + } + }, + "FontColor": { + "kind": "object", + "entries": { + "colorType": { + "description": "How the font color is defined, defaults to auto", + "optional": true, + "kind": "union", + "items": [ + { + "kind": "literal", + "value": "'auto'" + }, + { + "kind": "literal", + "value": "'colorPicker'" + }, + { + "kind": "literal", + "value": "'byExpression'" + } + ], + "type": "string" + }, + "color": { + "description": "Color defined by index or hex code, needed if colorType is colorPicker", + "optional": true, + "type": "#/definitions/PaletteColor" + }, + "colorExpression": { + "description": "Color defined by expression, needed if colorType is byExpression", + "optional": true, + "type": "#/definitions/ColorExpression" + } + } + }, + "PaletteColor": { + "description": "Color information structure. Holds the actual color and index in palette.", + "kind": "object", + "entries": { + "color": { + "description": "Color as hex string (only used if index: -1)", + "optional": true, + "type": "string" + }, + "index": { + "description": "Index in palette", + "optional": true, + "type": "number" + } + } + }, "properties.footnote": { "description": "Visualization footnote", "defaultValue": "", @@ -46,160 +192,7 @@ }, "properties.style": { "description": "Holds chart styling", - "kind": "object", - "entries": { - "backgroundColor": { - "description": "Hold background color details", - "kind": "object", - "entries": { - "color": { - "description": "Background color", - "kind": "object", - "entries": { - "color": { - "description": "Color defined by rgb, argb or html", - "defaultValue": "#ffffff", - "type": "string" - }, - "index": { - "description": "Index of theme color", - "defaultValue": -1, - "type": "number" - } - } - }, - "colorExpression": { - "description": "An expression to decide background color", - "defaultValue": "", - "type": "string" - }, - "colorType": { - "description": "How the background color is input", - "defaultValue": "colorPicker", - "kind": "union", - "items": [ - { - "kind": "literal", - "value": "'auto'" - }, - { - "kind": "literal", - "value": "'colorPicker'" - }, - { - "kind": "literal", - "value": "'byExpression'" - } - ], - "type": "string" - } - } - }, - "border": { - "description": "Holds border details", - "kind": "object", - "entries": { - "color": { - "description": "Border color", - "kind": "object", - "entries": { - "color": { - "description": "Color defined by rgb, argb or html", - "defaultValue": "#737373", - "type": "string" - }, - "index": { - "description": "Index of theme color", - "defaultValue": -1, - "type": "number" - } - } - }, - "colorExpression": { - "description": "An expression to decide border color", - "defaultValue": "", - "type": "string" - }, - "colorType": { - "description": "How the border color is input", - "defaultValue": "auto", - "kind": "union", - "items": [ - { - "kind": "literal", - "value": "'auto'" - }, - { - "kind": "literal", - "value": "'colorPicker'" - }, - { - "kind": "literal", - "value": "'byExpression'" - } - ], - "type": "string" - }, - "fullBorder": { - "description": "Show full border", - "defaultValue": true, - "type": "boolean" - }, - "top": { - "description": "Shop top border", - "defaultValue": true, - "type": "boolean" - } - } - }, - "fontColor": { - "description": "Holds font color details", - "kind": "object", - "entries": { - "color": { - "description": "Font color", - "kind": "object", - "entries": { - "color": { - "description": "Color defined by rgb, argb or html", - "defaultValue": "#484848", - "type": "string" - }, - "index": { - "description": "Index of theme color", - "defaultValue": -1, - "type": "number" - } - } - }, - "colorExpression": { - "description": "An expression to decide font color", - "defaultValue": "", - "type": "string" - }, - "colorType": { - "description": "How the font color is input", - "defaultValue": "auto", - "kind": "union", - "items": [ - { - "kind": "literal", - "value": "'auto'" - }, - { - "kind": "literal", - "value": "'colorPicker'" - }, - { - "kind": "literal", - "value": "'byExpression'" - } - ], - "type": "string" - } - } - } - } + "type": "#/definitions/Style" }, "properties.subtitle": { "description": "Visualization subtitle", @@ -210,6 +203,27 @@ "description": "Visualization title", "defaultValue": "", "type": "string" + }, + "Style": { + "description": "Holds styling options", + "kind": "object", + "entries": { + "fontColor": { + "description": "Color of the text, by default #484848", + "optional": true, + "type": "#/definitions/FontColor" + }, + "backgroundColor": { + "description": "Color of the background, by default #e6e6e6", + "optional": true, + "type": "#/definitions/Background" + }, + "border": { + "description": "Styling for border, by default #737373", + "optional": true, + "type": "#/definitions/Border" + } + } } } } \ No newline at end of file diff --git a/src/object-properties.js b/src/object-properties.js index 184df6d4..047b648c 100644 --- a/src/object-properties.js +++ b/src/object-properties.js @@ -37,9 +37,54 @@ const properties = { resizeOnExpand: false, /** * Holds chart styling - * @type {object} + * @type {Style} */ style: {}, }; +/** + * Holds styling options + * @typedef {object} Style + * @property {FontColor=} fontColor - Color of the text, by default #484848 + * @property {Background=} backgroundColor - Color of the background, by default #e6e6e6 + * @property {Border=} border - Styling for border, by default #737373 + */ + +/** + * @typedef {object} FontColor + * @property {('auto'|'colorPicker'|'byExpression')=} colorType - How the font color is defined, defaults to auto + * @property {PaletteColor=} color - Color defined by index or hex code, needed if colorType is colorPicker + * @property {ColorExpression=} colorExpression - Color defined by expression, needed if colorType is byExpression + */ + +/** + * @typedef {object} Background + * @property {('auto'|'colorPicker'|'byExpression')=} colorType - How the font color is defined, defaults to colorPicker + * @property {PaletteColor=} color - Color defined by index or hex code, needed if colorType is colorPicker + * @property {ColorExpression=} colorExpression - Color defined by expression, needed if colorType is byExpression + */ + +/** + * @typedef {object} Border + * @property {boolean=} top - Set to true to show thicker top border, default is true + * @property {boolean=} fullBorder - Set to true to show full border, default is true + * @property {('auto'|'colorPicker'|'byExpression')=} colorType - How the border color is defined, defaults to auto + * @property {PaletteColor=} color - Color defined by index or hex code, needed if colorType is colorPicker + * @property {ColorExpression=} colorExpression - Color defined by expression, needed if colorType is byExpression + */ + +/** + * Color information structure. Holds the actual color and index in palette. + * @typedef {object} PaletteColor + * @property {string=} color - Color as hex string (only used if index: -1) + * @property {number=} index - Index in palette + */ + +/** + * Format for using color expressions + * @typedef {object} ColorExpression + * @property {object} qStringExpression + * @property {string} qStringExpression.qExpr - expression that resolves to a supported color format + */ + export default properties;