Skip to content
This repository has been archived by the owner on Apr 23, 2024. It is now read-only.

Commit

Permalink
docs: add type definitions and generate api spec
Browse files Browse the repository at this point in the history
  • Loading branch information
eliseeborn committed Dec 1, 2021
1 parent e37c763 commit f1712fc
Show file tree
Hide file tree
Showing 2 changed files with 214 additions and 155 deletions.
322 changes: 168 additions & 154 deletions api-specifications/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "",
Expand Down Expand Up @@ -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",
Expand All @@ -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"
}
}
}
}
}
47 changes: 46 additions & 1 deletion src/object-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit f1712fc

Please sign in to comment.