From 242cd77ae6b8f18a105fb6497e098c395e52ffe2 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 2 Nov 2020 12:14:16 +0000 Subject: [PATCH 01/31] Set top level background colour --- packages/builder/src/global.css | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/builder/src/global.css b/packages/builder/src/global.css index 0616399dff..f059318bb0 100644 --- a/packages/builder/src/global.css +++ b/packages/builder/src/global.css @@ -28,6 +28,7 @@ html, body { margin: 0; height: 100%; width: 100%; + background-color: var(--background); } #app { From ab78620b32390b7a243069385c4a43c2de8d1302 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 2 Nov 2020 15:32:37 +0000 Subject: [PATCH 02/31] Add bar chart with initial apex charts config --- .../userInterface/temporaryPanelStructure.js | 800 +++++++++--------- packages/standard-components/components.json | 31 +- packages/standard-components/package.json | 9 +- .../src/Chart/ApexOptionsBuilder.js | 69 ++ .../standard-components/src/Chart/Bar.svelte | 217 +---- .../src/Chart/Brush.svelte | 118 --- .../src/Chart/Bullet.svelte | 103 --- .../src/Chart/Chart.svelte | 169 ---- .../src/Chart/Donut.svelte | 213 ----- .../src/Chart/GroupedBar.svelte | 145 ---- .../src/Chart/Heatmap.svelte | 83 -- .../src/Chart/Legend.svelte | 86 -- .../standard-components/src/Chart/Line.svelte | 256 ------ .../src/Chart/ScatterPlot.svelte | 187 ---- .../src/Chart/Sparkline.svelte | 103 --- .../src/Chart/StackedArea.svelte | 181 ---- .../src/Chart/StackedBar.svelte | 176 ---- .../standard-components/src/Chart/Step.svelte | 129 --- .../standard-components/src/Chart/Temp.svelte | 41 - .../src/Chart/Tooltip.svelte | 81 -- .../standard-components/src/Chart/index.js | 12 - .../src/Chart/tests/bar.html | 72 -- .../src/Chart/tests/line.html | 235 ----- .../standard-components/src/Chart/utils.js | 41 - .../standard-components/src/DataChart.svelte | 49 -- packages/standard-components/src/index.js | 4 +- 26 files changed, 518 insertions(+), 3092 deletions(-) create mode 100644 packages/standard-components/src/Chart/ApexOptionsBuilder.js delete mode 100644 packages/standard-components/src/Chart/Brush.svelte delete mode 100644 packages/standard-components/src/Chart/Bullet.svelte delete mode 100644 packages/standard-components/src/Chart/Chart.svelte delete mode 100644 packages/standard-components/src/Chart/Donut.svelte delete mode 100644 packages/standard-components/src/Chart/GroupedBar.svelte delete mode 100644 packages/standard-components/src/Chart/Heatmap.svelte delete mode 100644 packages/standard-components/src/Chart/Legend.svelte delete mode 100644 packages/standard-components/src/Chart/Line.svelte delete mode 100644 packages/standard-components/src/Chart/ScatterPlot.svelte delete mode 100644 packages/standard-components/src/Chart/Sparkline.svelte delete mode 100644 packages/standard-components/src/Chart/StackedArea.svelte delete mode 100644 packages/standard-components/src/Chart/StackedBar.svelte delete mode 100644 packages/standard-components/src/Chart/Step.svelte delete mode 100644 packages/standard-components/src/Chart/Temp.svelte delete mode 100644 packages/standard-components/src/Chart/Tooltip.svelte delete mode 100644 packages/standard-components/src/Chart/tests/bar.html delete mode 100644 packages/standard-components/src/Chart/tests/line.html delete mode 100644 packages/standard-components/src/Chart/utils.js delete mode 100644 packages/standard-components/src/DataChart.svelte diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 1c4bc632a6..2c8c50a0cb 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -422,100 +422,100 @@ export default { icon: "ri-bar-chart-2-line", isCategory: true, children: [ - { - name: "Donut", - _component: "@budibase/standard-components/donut", - description: "Donut chart", - icon: "ri-pie-chart-fill", - properties: { - settings: [ - { - label: "Data", - key: "datasource", - control: TableViewSelect, - }, - { - label: "Name Field", - key: "nameKey", - dependsOn: "datasource", - control: TableViewFieldSelect, - }, - { - label: "Value Field", - key: "valueKey", - dependsOn: "datasource", - control: TableViewFieldSelect, - }, - { - label: "Animate Chart", - key: "isAnimated", - valueKey: "checked", - control: Checkbox, - }, - { - label: "Hover Highlight", - key: "hasHoverAnimation", - valueKey: "checked", - control: Checkbox, - }, - { - label: "Keep Last Hover", - key: "hasLastHoverSliceHighlighted", - valueKey: "checked", - control: Checkbox, - }, - { - label: "Colors", - key: "color", - control: OptionSelect, - options: [ - "britecharts", - "blueGreen", - "green", - "grey", - "orange", - "pink", - "purple", - "red", - "teal", - "yellow", - ], - }, - { - label: "External Radius", - key: "externalRadius", - control: Input, - }, - { - label: "Internal Radius", - key: "internalRadius", - control: Input, - }, - { - label: "Radius Offset", - key: "radiusHoverOffset ", - control: Input, - }, - { - label: "Show Legend", - key: "useLegend ", - valueKey: "checked", - control: Checkbox, - }, - { - label: "Horizontal Legend", - key: "horizontalLegend", - valueKey: "checked", - control: Checkbox, - }, - { - label: "Legend Width", - key: "legendWidth", - control: Input, - }, - ], - }, - }, + // { + // name: "Donut", + // _component: "@budibase/standard-components/donut", + // description: "Donut chart", + // icon: "ri-pie-chart-fill", + // properties: { + // settings: [ + // { + // label: "Data", + // key: "datasource", + // control: TableViewSelect, + // }, + // { + // label: "Name Field", + // key: "nameKey", + // dependsOn: "datasource", + // control: TableViewFieldSelect, + // }, + // { + // label: "Value Field", + // key: "valueKey", + // dependsOn: "datasource", + // control: TableViewFieldSelect, + // }, + // { + // label: "Animate Chart", + // key: "isAnimated", + // valueKey: "checked", + // control: Checkbox, + // }, + // { + // label: "Hover Highlight", + // key: "hasHoverAnimation", + // valueKey: "checked", + // control: Checkbox, + // }, + // { + // label: "Keep Last Hover", + // key: "hasLastHoverSliceHighlighted", + // valueKey: "checked", + // control: Checkbox, + // }, + // { + // label: "Colors", + // key: "color", + // control: OptionSelect, + // options: [ + // "britecharts", + // "blueGreen", + // "green", + // "grey", + // "orange", + // "pink", + // "purple", + // "red", + // "teal", + // "yellow", + // ], + // }, + // { + // label: "External Radius", + // key: "externalRadius", + // control: Input, + // }, + // { + // label: "Internal Radius", + // key: "internalRadius", + // control: Input, + // }, + // { + // label: "Radius Offset", + // key: "radiusHoverOffset ", + // control: Input, + // }, + // { + // label: "Show Legend", + // key: "useLegend ", + // valueKey: "checked", + // control: Checkbox, + // }, + // { + // label: "Horizontal Legend", + // key: "horizontalLegend", + // valueKey: "checked", + // control: Checkbox, + // }, + // { + // label: "Legend Width", + // key: "legendWidth", + // control: Input, + // }, + // ], + // }, + // }, { name: "Bar", _component: "@budibase/standard-components/bar", @@ -529,13 +529,13 @@ export default { control: TableViewSelect, }, { - label: "Name Label", + label: "Label Col.", key: "nameLabel", dependsOn: "datasource", control: TableViewFieldSelect, }, { - label: "Value Label", + label: "Value Col.", key: "valueLabel", dependsOn: "datasource", control: TableViewFieldSelect, @@ -550,291 +550,11 @@ export default { key: "xAxisLabel", control: Input, }, - { - label: "X Axis Label Offset", - key: "xAxisLabelOffset", - control: Input, - }, - { - label: "Y Axis Label Offset", - key: "yAxisLabelOffset", - control: Input, - }, - { - label: "Enable Labels", - key: "enableLabels", - control: Checkbox, - valueKey: "checked", - }, - { - label: "Colors", - key: "color", - control: OptionSelect, - options: [ - { label: "Normal", value: "britecharts" }, - { label: "Blue Green", value: "blueGreen" }, - { label: "Green", value: "green" }, - { label: "Grey", value: "grey" }, - { label: "Orange", value: "orange" }, - { label: "Pink", value: "pink" }, - { label: "Purple", value: "purple" }, - { label: "Red", value: "red" }, - { label: "Teal", value: "teal" }, - { label: "Yellow", value: "yellow" }, - ], - }, - { - label: "Gradients", - key: "gradient", - control: OptionSelect, - options: [ - { value: "", label: "None" }, - { value: "bluePurple", label: "Blue Purple" }, - { value: "greenBlue", label: "Green Blue" }, - { value: "orangePink", label: "Orange Pink" }, - ], - }, - { - label: "Highlight Single Bar", - key: "hasSingleBarHighlight", - control: Checkbox, - valueKey: "checked", - }, - { - label: "Width", - key: "width", - control: Input, - }, - { - label: "Height", - key: "height", - control: Input, - }, - { - label: "Animate", - key: "isAnimate", - control: Checkbox, - valueKey: "checked", - }, - { - label: "Horizontal", - key: "isHorizontal", - control: Checkbox, - valueKey: "checked", - }, - { - label: "Label Number Format", - key: "labelsNumberFormat", - control: Input, - }, - ], - }, - }, - { - name: "Grouped Bar", - _component: "@budibase/standard-components/groupedbar", - description: "Groupedbar chart", - icon: "ri-bar-chart-grouped-fill", - properties: { - settings: [ - { - label: "Data", - key: "datasource", - control: TableViewSelect, - }, - { - label: "Name Label", - key: "nameLabel", - dependsOn: "datasource", - control: TableViewFieldSelect, - }, - { - label: "Group Label", - key: "groupLabel", - dependsOn: "datasource", - control: TableViewFieldSelect, - }, - { - label: "Value Label", - key: "valueLabel", - dependsOn: "datasource", - control: TableViewFieldSelect, - }, { label: "Color", key: "color", - control: OptionSelect, - options: [ - "britecharts", - "blueGreen", - "green", - "grey", - "orange", - "pink", - "purple", - "red", - "teal", - "yellow", - ], - }, - { - label: "Height", - key: "height", - control: Input, - }, - { - label: "Width", - key: "width", - control: Input, - }, - { - label: "Aspect Ratio", - key: "aspectRatio", - control: Input, - }, - { - label: "Grid", - key: "grid", - control: OptionSelect, - options: ["vertical", "horizontal", "full"], - }, - { - label: "Value Label", - key: "valueLabel", - control: Input, - }, - { - label: "Y Ticks", - key: "yTicks", - control: Input, - }, - { - label: "Y Tick Text Offset", - key: "yTickTextOffset", - control: Input, - }, - { - label: "Is Animated", - key: "isAnimated", - valueKey: "checked", - control: Checkbox, - }, - { - label: "Is Horizontal", - key: "isHorizontal", - valueKey: "checked", - control: Checkbox, - }, - { - label: "Tooltip Title", - key: "tooltipTitle", - control: Input, - }, - ], - }, - }, - { - name: "Line", - _component: "@budibase/standard-components/line", - description: "Line chart", - icon: "ri-line-chart-line", - properties: { - settings: [ - { - label: "Data", - key: "datasource", - control: TableViewSelect, - }, - { - label: "Value Label", - key: "valueLabel", - dependsOn: "datasource", - control: TableViewFieldSelect, - }, - { - label: "Topic Label", - key: "topicLabel", - dependsOn: "datasource", - control: TableViewFieldSelect, - }, - { - label: "Date Label", - key: "dateLabel", - dependsOn: "datasource", - control: TableViewFieldSelect, - }, - { - label: "Colors", - key: "color", - control: OptionSelect, - options: [ - "britecharts", - "blueGreen", - "green", - "grey", - "orange", - "pink", - "purple", - "red", - "teal", - "yellow", - ], - }, - { - label: "Gradients", - key: "lineGradient", - control: OptionSelect, - options: [ - { value: "", label: "None" }, - { value: "bluePurple", label: "Blue Purple" }, - { value: "greenBlue", label: "Green Blue" }, - { value: "orangePink", label: "Orange Pink" }, - ], - }, - { - label: "Line Curve", - key: "lineCurve", - control: OptionSelect, - options: [ - "linear", - "basis", - "natural", - "monotoneX", - "monotoneY", - "step", - "stepAfter", - "stepBefore", - "cardinal", - "catmullRom", - ], - }, - { - label: "X Axis Value Type", - key: "xAxisValueType", - control: OptionSelect, - options: ["date", "number"], - }, - { - label: "Grid", - key: "grid", - control: OptionSelect, - options: ["vertical", "horizontal", "full"], - }, - { - label: "X Axis Label", - key: "xAxisLabel", - control: Input, - }, - { - label: "Y Axis Label", - key: "yAxisLabel", - control: Input, - }, - { - label: "Show All Datapoints", - key: "shouldShowAllDataPoints", - valueKey: "checked", - control: Checkbox, + control: Colorpicker, + defaultValue: "#4285f4", }, { label: "Width", @@ -845,60 +565,300 @@ export default { label: "Height", key: "height", control: Input, + defaultValue: "400", }, { - label: "Is Animated", - key: "isAnimated", + label: "Horizontal", + key: "horizontal", control: Checkbox, valueKey: "checked", }, { - label: "Locale", - key: "locale", - control: OptionSelect, - options: ["en-GB", "en-US"], + label: "Data Labels", + key: "dataLabels", + control: Checkbox, + valueKey: "checked", + defaultValue: true, }, { - label: "X Axis Value Type", - key: "xAxisValueType", - control: OptionSelect, - options: ["date", "numeric"], - }, - { - label: "X Axis Format", - key: "xAxisFormat", - control: OptionSelect, - options: [ - "day-month", - "minute-hour", - "hour-daymonth", - "month-year", - "custom", - ], - }, - { - label: "X Axis Custom Format", - key: "xAxisCustomFormat", - control: Input, - }, - { - label: "Tooltip Title", - key: "tooltipTitle", - control: Input, - }, - { - label: "X Ticks", - key: "xTicks", - control: Input, - }, - { - label: "Y Ticks", - key: "yTicks", - control: Input, + label: "Animate", + key: "animate", + control: Checkbox, + valueKey: "checked", + defaultValue: true, }, ], }, }, + // { + // name: "Grouped Bar", + // _component: "@budibase/standard-components/groupedbar", + // description: "Groupedbar chart", + // icon: "ri-bar-chart-grouped-fill", + // properties: { + // settings: [ + // { + // label: "Data", + // key: "datasource", + // control: TableViewSelect, + // }, + // { + // label: "Name Label", + // key: "nameLabel", + // dependsOn: "datasource", + // control: TableViewFieldSelect, + // }, + // { + // label: "Group Label", + // key: "groupLabel", + // dependsOn: "datasource", + // control: TableViewFieldSelect, + // }, + // { + // label: "Value Label", + // key: "valueLabel", + // dependsOn: "datasource", + // control: TableViewFieldSelect, + // }, + // { + // label: "Color", + // key: "color", + // control: OptionSelect, + // options: [ + // "britecharts", + // "blueGreen", + // "green", + // "grey", + // "orange", + // "pink", + // "purple", + // "red", + // "teal", + // "yellow", + // ], + // }, + // { + // label: "Height", + // key: "height", + // control: Input, + // }, + // { + // label: "Width", + // key: "width", + // control: Input, + // }, + // { + // label: "Aspect Ratio", + // key: "aspectRatio", + // control: Input, + // }, + // { + // label: "Grid", + // key: "grid", + // control: OptionSelect, + // options: ["vertical", "horizontal", "full"], + // }, + // { + // label: "Value Label", + // key: "valueLabel", + // control: Input, + // }, + // { + // label: "Y Ticks", + // key: "yTicks", + // control: Input, + // }, + // { + // label: "Y Tick Text Offset", + // key: "yTickTextOffset", + // control: Input, + // }, + // { + // label: "Is Animated", + // key: "isAnimated", + // valueKey: "checked", + // control: Checkbox, + // }, + // { + // label: "Is Horizontal", + // key: "isHorizontal", + // valueKey: "checked", + // control: Checkbox, + // }, + // { + // label: "Tooltip Title", + // key: "tooltipTitle", + // control: Input, + // }, + // ], + // }, + // }, + // { + // name: "Line", + // _component: "@budibase/standard-components/line", + // description: "Line chart", + // icon: "ri-line-chart-line", + // properties: { + // settings: [ + // { + // label: "Data", + // key: "datasource", + // control: TableViewSelect, + // }, + // { + // label: "Value Label", + // key: "valueLabel", + // dependsOn: "datasource", + // control: TableViewFieldSelect, + // }, + // { + // label: "Topic Label", + // key: "topicLabel", + // dependsOn: "datasource", + // control: TableViewFieldSelect, + // }, + // { + // label: "Date Label", + // key: "dateLabel", + // dependsOn: "datasource", + // control: TableViewFieldSelect, + // }, + // { + // label: "Colors", + // key: "color", + // control: OptionSelect, + // options: [ + // "britecharts", + // "blueGreen", + // "green", + // "grey", + // "orange", + // "pink", + // "purple", + // "red", + // "teal", + // "yellow", + // ], + // }, + // { + // label: "Gradients", + // key: "lineGradient", + // control: OptionSelect, + // options: [ + // { value: "", label: "None" }, + // { value: "bluePurple", label: "Blue Purple" }, + // { value: "greenBlue", label: "Green Blue" }, + // { value: "orangePink", label: "Orange Pink" }, + // ], + // }, + // { + // label: "Line Curve", + // key: "lineCurve", + // control: OptionSelect, + // options: [ + // "linear", + // "basis", + // "natural", + // "monotoneX", + // "monotoneY", + // "step", + // "stepAfter", + // "stepBefore", + // "cardinal", + // "catmullRom", + // ], + // }, + // { + // label: "X Axis Value Type", + // key: "xAxisValueType", + // control: OptionSelect, + // options: ["date", "number"], + // }, + // { + // label: "Grid", + // key: "grid", + // control: OptionSelect, + // options: ["vertical", "horizontal", "full"], + // }, + // { + // label: "X Axis Label", + // key: "xAxisLabel", + // control: Input, + // }, + // { + // label: "Y Axis Label", + // key: "yAxisLabel", + // control: Input, + // }, + // { + // label: "Show All Datapoints", + // key: "shouldShowAllDataPoints", + // valueKey: "checked", + // control: Checkbox, + // }, + // { + // label: "Width", + // key: "width", + // control: Input, + // }, + // { + // label: "Height", + // key: "height", + // control: Input, + // }, + // { + // label: "Is Animated", + // key: "isAnimated", + // control: Checkbox, + // valueKey: "checked", + // }, + // { + // label: "Locale", + // key: "locale", + // control: OptionSelect, + // options: ["en-GB", "en-US"], + // }, + // { + // label: "X Axis Value Type", + // key: "xAxisValueType", + // control: OptionSelect, + // options: ["date", "numeric"], + // }, + // { + // label: "X Axis Format", + // key: "xAxisFormat", + // control: OptionSelect, + // options: [ + // "day-month", + // "minute-hour", + // "hour-daymonth", + // "month-year", + // "custom", + // ], + // }, + // { + // label: "X Axis Custom Format", + // key: "xAxisCustomFormat", + // control: Input, + // }, + // { + // label: "Tooltip Title", + // key: "tooltipTitle", + // control: Input, + // }, + // { + // label: "X Ticks", + // key: "xTicks", + // control: Input, + // }, + // { + // label: "Y Ticks", + // key: "yTicks", + // control: Input, + // }, + // ], + // }, + // }, ], }, { diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index 9adb3c02cf..f63ce9d56b 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -552,21 +552,26 @@ "datasource": "tables", "nameLabel": "string", "valueLabel": "string", - "betweenBarsPadding": "number", - "gradient": "string", - "color": "string", - "hasSingleBarHighlight": "bool", - "height": "number", + "color": { + "type": "string", + "default": "#4285f4" + }, + "height": { + "type": "number", + "default": "400" + }, "width": "number", - "isAnimated": "bool", - "isHorizontal": "bool", - "labelNumberFormat": "number", - "locale": "string", + "horizontal": "bool", + "dataLabels": { + "type": "bool", + "default": true + }, + "animate": { + "type": "bool", + "default": true + }, "xAxisLabel": "string", - "yAxisLabel": "string", - "useLegend": "bool", - "xTicks": "number", - "yTicks": "number" + "yAxisLabel": "string" } }, "line": { diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 9b2fca0f54..720d704618 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -35,18 +35,15 @@ "license": "MIT", "gitHead": "284cceb9b703c38566c6e6363c022f79a08d5691", "dependencies": { - "@beyonk/svelte-googlemaps": "^2.2.0", "@budibase/bbui": "^1.50.1", "@budibase/svelte-ag-grid": "^0.0.13", "@fortawesome/fontawesome-free": "^5.14.0", "@svelteschool/svelte-forms": "^0.7.0", - "britecharts": "^2.16.1", - "d3-selection": "^1.4.2", + "apexcharts": "^3.22.1", "fast-sort": "^2.2.0", "flatpickr": "^4.6.6", - "fusioncharts": "^3.15.1-sr.1", "lodash.debounce": "^4.0.8", - "svelte-flatpickr": "^3.1.0", - "svelte-fusioncharts": "^1.0.0" + "svelte-apexcharts": "^1.0.2", + "svelte-flatpickr": "^3.1.0" } } diff --git a/packages/standard-components/src/Chart/ApexOptionsBuilder.js b/packages/standard-components/src/Chart/ApexOptionsBuilder.js new file mode 100644 index 0000000000..4fb66e90f6 --- /dev/null +++ b/packages/standard-components/src/Chart/ApexOptionsBuilder.js @@ -0,0 +1,69 @@ +export class ApexOptionsBuilder { + options = { + series: [], + } + + setOption(path, value) { + if (value == null || value === "") { + return this + } + let tmp = this.options + for (let i = 0; i < path.length - 1; i++) { + const step = path[i] + if (!tmp[step]) { + tmp[step] = {} + } + tmp = tmp[step] + } + tmp[path[path.length - 1]] = value + return this + } + + getOptions() { + return this.options + } + + type(type) { + return this.setOption(["chart", "type"], type) + } + + color(color) { + return this.setOption(["colors"], color) + } + + width(width) { + return this.setOption(["chart", "width"], width || undefined) + } + + height(height) { + return this.setOption(["chart", "height"], height || undefined) + } + + xLabel(label) { + return this.setOption(["xaxis", "title", "text"], label) + } + + yLabel(label) { + return this.setOption(["yaxis", "title", "text"], label) + } + + categories(categories) { + return this.setOption(["xaxis", "categories"], categories) + } + + series(series) { + return this.setOption(["series"], series) + } + + horizontal(horizontal) { + return this.setOption(["plotOptions", "bar", "horizontal"], horizontal) + } + + dataLabels(dataLabels) { + return this.setOption(["dataLabels", "enabled"], dataLabels) + } + + animate(animate) { + return this.setOption(["chart", "animations", "enabled"], animate) + } +} diff --git a/packages/standard-components/src/Chart/Bar.svelte b/packages/standard-components/src/Chart/Bar.svelte index 24da930e14..d73a0681a3 100644 --- a/packages/standard-components/src/Chart/Bar.svelte +++ b/packages/standard-components/src/Chart/Bar.svelte @@ -1,187 +1,64 @@ -
+
diff --git a/packages/standard-components/src/Chart/Brush.svelte b/packages/standard-components/src/Chart/Brush.svelte deleted file mode 100644 index d1e736074b..0000000000 --- a/packages/standard-components/src/Chart/Brush.svelte +++ /dev/null @@ -1,118 +0,0 @@ - - -
diff --git a/packages/standard-components/src/Chart/Bullet.svelte b/packages/standard-components/src/Chart/Bullet.svelte deleted file mode 100644 index 04f3ef1648..0000000000 --- a/packages/standard-components/src/Chart/Bullet.svelte +++ /dev/null @@ -1,103 +0,0 @@ - - -
diff --git a/packages/standard-components/src/Chart/Chart.svelte b/packages/standard-components/src/Chart/Chart.svelte deleted file mode 100644 index 3f1634719a..0000000000 --- a/packages/standard-components/src/Chart/Chart.svelte +++ /dev/null @@ -1,169 +0,0 @@ - - - - -
-{#if useLegend} -
-{/if} diff --git a/packages/standard-components/src/Chart/Donut.svelte b/packages/standard-components/src/Chart/Donut.svelte deleted file mode 100644 index 89b314e3db..0000000000 --- a/packages/standard-components/src/Chart/Donut.svelte +++ /dev/null @@ -1,213 +0,0 @@ - - -
-
- {#if data.length > 0} - - {/if} -
diff --git a/packages/standard-components/src/Chart/GroupedBar.svelte b/packages/standard-components/src/Chart/GroupedBar.svelte deleted file mode 100644 index 3f95a778c8..0000000000 --- a/packages/standard-components/src/Chart/GroupedBar.svelte +++ /dev/null @@ -1,145 +0,0 @@ - - -
diff --git a/packages/standard-components/src/Chart/Heatmap.svelte b/packages/standard-components/src/Chart/Heatmap.svelte deleted file mode 100644 index 9d2eb8d878..0000000000 --- a/packages/standard-components/src/Chart/Heatmap.svelte +++ /dev/null @@ -1,83 +0,0 @@ - - -
-{#if useLegend} -
-{/if} diff --git a/packages/standard-components/src/Chart/Legend.svelte b/packages/standard-components/src/Chart/Legend.svelte deleted file mode 100644 index a5745f25d1..0000000000 --- a/packages/standard-components/src/Chart/Legend.svelte +++ /dev/null @@ -1,86 +0,0 @@ - - -{#if useLegend} -
-{/if} diff --git a/packages/standard-components/src/Chart/Line.svelte b/packages/standard-components/src/Chart/Line.svelte deleted file mode 100644 index b6f5452072..0000000000 --- a/packages/standard-components/src/Chart/Line.svelte +++ /dev/null @@ -1,256 +0,0 @@ - - -
diff --git a/packages/standard-components/src/Chart/ScatterPlot.svelte b/packages/standard-components/src/Chart/ScatterPlot.svelte deleted file mode 100644 index cc775fa6ee..0000000000 --- a/packages/standard-components/src/Chart/ScatterPlot.svelte +++ /dev/null @@ -1,187 +0,0 @@ - - -
-{#if useLegend} -
-{/if} diff --git a/packages/standard-components/src/Chart/Sparkline.svelte b/packages/standard-components/src/Chart/Sparkline.svelte deleted file mode 100644 index 920843a080..0000000000 --- a/packages/standard-components/src/Chart/Sparkline.svelte +++ /dev/null @@ -1,103 +0,0 @@ - - -
-{#if useLegend} -
-{/if} diff --git a/packages/standard-components/src/Chart/StackedArea.svelte b/packages/standard-components/src/Chart/StackedArea.svelte deleted file mode 100644 index 04116c29f6..0000000000 --- a/packages/standard-components/src/Chart/StackedArea.svelte +++ /dev/null @@ -1,181 +0,0 @@ - - -
-{#if useLegend} -
-{/if} diff --git a/packages/standard-components/src/Chart/StackedBar.svelte b/packages/standard-components/src/Chart/StackedBar.svelte deleted file mode 100644 index f6e7a7a921..0000000000 --- a/packages/standard-components/src/Chart/StackedBar.svelte +++ /dev/null @@ -1,176 +0,0 @@ - - -
-{#if useLegend} -
-{/if} diff --git a/packages/standard-components/src/Chart/Step.svelte b/packages/standard-components/src/Chart/Step.svelte deleted file mode 100644 index b193d78f4c..0000000000 --- a/packages/standard-components/src/Chart/Step.svelte +++ /dev/null @@ -1,129 +0,0 @@ - - -
-{#if useLegend} -
-{/if} diff --git a/packages/standard-components/src/Chart/Temp.svelte b/packages/standard-components/src/Chart/Temp.svelte deleted file mode 100644 index 1703c7b604..0000000000 --- a/packages/standard-components/src/Chart/Temp.svelte +++ /dev/null @@ -1,41 +0,0 @@ - - -
-{#if useLegend} -
-{/if} diff --git a/packages/standard-components/src/Chart/Tooltip.svelte b/packages/standard-components/src/Chart/Tooltip.svelte deleted file mode 100644 index f2898c9607..0000000000 --- a/packages/standard-components/src/Chart/Tooltip.svelte +++ /dev/null @@ -1,81 +0,0 @@ - diff --git a/packages/standard-components/src/Chart/index.js b/packages/standard-components/src/Chart/index.js index a94abf8ac8..0dafa8a70d 100644 --- a/packages/standard-components/src/Chart/index.js +++ b/packages/standard-components/src/Chart/index.js @@ -1,14 +1,2 @@ -import "britecharts/dist/css/britecharts.min.css" - -export { default as donut } from "./Donut.svelte" export { default as bar } from "./Bar.svelte" export { default as line } from "./Line.svelte" -export { default as brush } from "./Brush.svelte" -export { default as bullet } from "./Bullet.svelte" -export { default as groupedbar } from "./GroupedBar.svelte" -export { default as heatmap } from "./Heatmap.svelte" -export { default as sparkline } from "./Sparkline.svelte" -export { default as scatterplot } from "./ScatterPlot.svelte" -export { default as step } from "./Step.svelte" -export { default as stackedarea } from "./StackedArea.svelte" -export { default as stackedbar } from "./StackedBar.svelte" diff --git a/packages/standard-components/src/Chart/tests/bar.html b/packages/standard-components/src/Chart/tests/bar.html deleted file mode 100644 index 9828587375..0000000000 --- a/packages/standard-components/src/Chart/tests/bar.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - Document - - - - - - - - - -
-

Bar Chart

-
-
- - - - \ No newline at end of file diff --git a/packages/standard-components/src/Chart/tests/line.html b/packages/standard-components/src/Chart/tests/line.html deleted file mode 100644 index 0340a3ddd4..0000000000 --- a/packages/standard-components/src/Chart/tests/line.html +++ /dev/null @@ -1,235 +0,0 @@ - - - - - - HTML Line - - - - - - - - - - - - - -
-
-
- - - - - \ No newline at end of file diff --git a/packages/standard-components/src/Chart/utils.js b/packages/standard-components/src/Chart/utils.js deleted file mode 100644 index 7cd682e88d..0000000000 --- a/packages/standard-components/src/Chart/utils.js +++ /dev/null @@ -1,41 +0,0 @@ -import britecharts from "britecharts" - -export const notNull = value => value || value === false - -export const hasProp = (data, prop) => data.every(d => prop in d) - -export const chartTypes = britecharts ? Object.keys(britecharts) : null - -//expose chart color schemas for use or reference outside compnent -export const colorSchemas = britecharts ? britecharts.colors.colorSchemas : null - -//export color gradients for use or reference outside the component -export const colorGradients = britecharts - ? britecharts.colors.colorGradients - : null - -export const getColorSchema = color => - color ? colorSchemas[color] : colorSchemas["britecharts"] - -export const getChartGradient = gradient => - gradient ? colorGradients[gradient] : null - -export function reformatDataKey(data = [], dataKey = null, formatKey = null) { - let ignoreList = ["_id", "_rev", "id"] - if (dataKey && data.every(d => d[dataKey])) { - return data.map(d => { - let clonedRow = { ...d } - if (clonedRow[formatKey]) { - delete clonedRow[formatKey] - } - let value = clonedRow[dataKey] - if (!ignoreList.includes(dataKey)) { - delete clonedRow[dataKey] - } - clonedRow[formatKey] = value - return clonedRow - }) - } else { - return data - } -} diff --git a/packages/standard-components/src/DataChart.svelte b/packages/standard-components/src/DataChart.svelte deleted file mode 100644 index 4948fa2cc6..0000000000 --- a/packages/standard-components/src/DataChart.svelte +++ /dev/null @@ -1,49 +0,0 @@ - - -
- -
diff --git a/packages/standard-components/src/index.js b/packages/standard-components/src/index.js index c99c2cbe56..60473bec70 100644 --- a/packages/standard-components/src/index.js +++ b/packages/standard-components/src/index.js @@ -5,7 +5,6 @@ export { default as text } from "./Text.svelte" export { default as heading } from "./Heading.svelte" export { default as input } from "./Input.svelte" export { default as textfield } from "./Textfield.svelte" - export { default as button } from "./Button.svelte" export { default as login } from "./Login.svelte" export { default as saveRowButton } from "./Templates/saveRowButton" @@ -15,7 +14,6 @@ export { default as Navigation } from "./Navigation.svelte" export { default as datagrid } from "./DataGrid/Component.svelte" export { default as dataform } from "./DataForm.svelte" export { default as dataformwide } from "./DataFormWide.svelte" -export { default as datachart } from "./DataChart.svelte" export { default as datalist } from "./DataList.svelte" export { default as list } from "./List.svelte" export { default as datasearch } from "./DataSearch.svelte" @@ -26,5 +24,5 @@ export { default as cardhorizontal } from "./CardHorizontal.svelte" export { default as rowdetail } from "./RowDetail.svelte" export { default as newrow } from "./NewRow.svelte" export { default as datepicker } from "./DatePicker.svelte" -export * from "./Chart" export { default as icon } from "./Icon.svelte" +export * from "./Chart" From 75bfa602312205b0f2a68ccc602d4e673981c0f6 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Nov 2020 09:39:42 +0000 Subject: [PATCH 03/31] Fix evil falsiness bug with frontend property settings checkboxes --- .../builder/src/components/userInterface/PropertyControl.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/userInterface/PropertyControl.svelte b/packages/builder/src/components/userInterface/PropertyControl.svelte index e9dfb0abfc..a05013d744 100644 --- a/packages/builder/src/components/userInterface/PropertyControl.svelte +++ b/packages/builder/src/components/userInterface/PropertyControl.svelte @@ -72,7 +72,7 @@ let temp = runtimeToReadableBinding(bindableProperties, value) - return !value && props.defaultValue !== undefined + return value == null && props.defaultValue !== undefined ? props.defaultValue : temp } From 465f2a6fbdb96a65461aac79f4d9e04a65b0cc00 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Nov 2020 09:42:46 +0000 Subject: [PATCH 04/31] Add multi option select and multi table view field select components --- .../userInterface/MultiOptionSelect.svelte | 39 +++++++++++++++++++ .../MultiTableViewFieldSelect.svelte | 5 +++ .../userInterface/TableViewFieldSelect.svelte | 11 ++++-- 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 packages/builder/src/components/userInterface/MultiOptionSelect.svelte create mode 100644 packages/builder/src/components/userInterface/MultiTableViewFieldSelect.svelte diff --git a/packages/builder/src/components/userInterface/MultiOptionSelect.svelte b/packages/builder/src/components/userInterface/MultiOptionSelect.svelte new file mode 100644 index 0000000000..30ad7672ff --- /dev/null +++ b/packages/builder/src/components/userInterface/MultiOptionSelect.svelte @@ -0,0 +1,39 @@ + + +
+ + {#each options as option} + + {/each} + +
+ + diff --git a/packages/builder/src/components/userInterface/MultiTableViewFieldSelect.svelte b/packages/builder/src/components/userInterface/MultiTableViewFieldSelect.svelte new file mode 100644 index 0000000000..7d2f17a02b --- /dev/null +++ b/packages/builder/src/components/userInterface/MultiTableViewFieldSelect.svelte @@ -0,0 +1,5 @@ + + + diff --git a/packages/builder/src/components/userInterface/TableViewFieldSelect.svelte b/packages/builder/src/components/userInterface/TableViewFieldSelect.svelte index 30e1becca8..756936be82 100644 --- a/packages/builder/src/components/userInterface/TableViewFieldSelect.svelte +++ b/packages/builder/src/components/userInterface/TableViewFieldSelect.svelte @@ -1,11 +1,12 @@ - +{#if multiselect} + +{:else} + +{/if} From 4873c669949e1c255db828d78beeb3d4adef37cc Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Nov 2020 09:43:08 +0000 Subject: [PATCH 05/31] Tidy up option select --- .../builder/src/components/userInterface/OptionSelect.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/userInterface/OptionSelect.svelte b/packages/builder/src/components/userInterface/OptionSelect.svelte index 6cd61a15f7..cabb9a8efc 100644 --- a/packages/builder/src/components/userInterface/OptionSelect.svelte +++ b/packages/builder/src/components/userInterface/OptionSelect.svelte @@ -1,12 +1,12 @@ + +
diff --git a/packages/standard-components/src/Chart/index.js b/packages/standard-components/src/Chart/index.js index 0dafa8a70d..5a9e94f00d 100644 --- a/packages/standard-components/src/Chart/index.js +++ b/packages/standard-components/src/Chart/index.js @@ -1,2 +1,2 @@ -export { default as bar } from "./Bar.svelte" -export { default as line } from "./Line.svelte" +export { default as bar } from "./BarChart.svelte" +export { default as line } from "./LineChart.svelte" From ae876c6c09913ede8de70230b95ff453815df27d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Nov 2020 09:48:35 +0000 Subject: [PATCH 07/31] Add stacked option to bar chart --- .../components/userInterface/temporaryPanelStructure.js | 7 +++++++ packages/standard-components/components.json | 6 ++---- .../standard-components/src/Chart/ApexOptionsBuilder.js | 4 ++++ packages/standard-components/src/Chart/BarChart.svelte | 2 ++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 05925b9b61..42410c62f3 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -573,6 +573,13 @@ export default { control: Input, defaultValue: "400", }, + { + label: "Stacked", + key: "stacked", + control: Checkbox, + valueKey: "checked", + defaultValue: false, + }, { label: "Horizontal", key: "horizontal", diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index 5a93ef2c2f..b9dab63fe2 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -573,10 +573,8 @@ }, "xAxisLabel": "string", "yAxisLabel": "string", - "legend": { - "type": "bool", - "default": false - } + "legend": "bool", + "stacked": "bool" } }, "line": { diff --git a/packages/standard-components/src/Chart/ApexOptionsBuilder.js b/packages/standard-components/src/Chart/ApexOptionsBuilder.js index 30723f0b28..9df273d7d7 100644 --- a/packages/standard-components/src/Chart/ApexOptionsBuilder.js +++ b/packages/standard-components/src/Chart/ApexOptionsBuilder.js @@ -104,4 +104,8 @@ export class ApexOptionsBuilder { legend(legend) { return this.setOption(["legend", "show"], legend) } + + stacked(stacked) { + return this.setOption(["chart", "stacked"], stacked) + } } diff --git a/packages/standard-components/src/Chart/BarChart.svelte b/packages/standard-components/src/Chart/BarChart.svelte index edc0f8dcc1..de51316ed4 100644 --- a/packages/standard-components/src/Chart/BarChart.svelte +++ b/packages/standard-components/src/Chart/BarChart.svelte @@ -18,6 +18,7 @@ export let dataLabels export let animate export let legend + export let stacked let data $: options = getChartOptions(data) @@ -43,6 +44,7 @@ .dataLabels(dataLabels) .animate(animate) .legend(legend) + .stacked(stacked) // Add data if valid datasource if (rows && rows.length) { From 0aa672f3b37379b1cb432c65f1c51aced2e5be83 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Nov 2020 09:48:58 +0000 Subject: [PATCH 08/31] Remove log statement --- .../src/components/userInterface/MultiOptionSelect.svelte | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/builder/src/components/userInterface/MultiOptionSelect.svelte b/packages/builder/src/components/userInterface/MultiOptionSelect.svelte index 30ad7672ff..47a146cae6 100644 --- a/packages/builder/src/components/userInterface/MultiOptionSelect.svelte +++ b/packages/builder/src/components/userInterface/MultiOptionSelect.svelte @@ -15,7 +15,6 @@ } function setValue(val) { - console.log(val) onChange(val) } From 4f2079509c94bfb59e27dba6e40a8e26d5a65393 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Nov 2020 10:03:19 +0000 Subject: [PATCH 09/31] Remove log statement --- packages/standard-components/src/Chart/LineChart.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/standard-components/src/Chart/LineChart.svelte b/packages/standard-components/src/Chart/LineChart.svelte index 599ce1fed1..be5d3a94e4 100644 --- a/packages/standard-components/src/Chart/LineChart.svelte +++ b/packages/standard-components/src/Chart/LineChart.svelte @@ -64,8 +64,6 @@ // Build chart options return builder.getOptions() } - - $: console.log(options)
From bcc86af4b46d8c60fc9b533fbd0d61ba91dbaf9c Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Nov 2020 10:09:22 +0000 Subject: [PATCH 10/31] Fix multi option select handling of default value being hardcoded to a string --- .../src/components/userInterface/MultiOptionSelect.svelte | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/builder/src/components/userInterface/MultiOptionSelect.svelte b/packages/builder/src/components/userInterface/MultiOptionSelect.svelte index 47a146cae6..5122969975 100644 --- a/packages/builder/src/components/userInterface/MultiOptionSelect.svelte +++ b/packages/builder/src/components/userInterface/MultiOptionSelect.svelte @@ -11,6 +11,10 @@ $: sanitiseOptions(options) function getValidOptions(selectedOptions, allOptions) { + // Fix the hardcoded default string value + if (!Array.isArray(selectedOptions)) { + selectedOptions = [] + } return selectedOptions.filter(val => allOptions.indexOf(val) !== -1) } From ff15205277e0abb32ed50c1c86b49c2c717f2d1d Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Nov 2020 10:09:41 +0000 Subject: [PATCH 11/31] Fix another evil falsiness bug with setting checkboxes --- .../builder/src/components/userInterface/SettingsView.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/userInterface/SettingsView.svelte b/packages/builder/src/components/userInterface/SettingsView.svelte index 2aacbd261b..d4968c78ee 100644 --- a/packages/builder/src/components/userInterface/SettingsView.svelte +++ b/packages/builder/src/components/userInterface/SettingsView.svelte @@ -118,7 +118,7 @@ control={definition.control} label={definition.label} key={definition.key} - value={componentInstance[definition.key] || componentInstance[definition.key]?.defaultValue} + value={componentInstance[definition.key] ?? componentInstance[definition.key]?.defaultValue} {componentInstance} {onChange} props={{ ...excludeProps(definition, ['control', 'label']) }} /> From 3e06d393e1e5dac37a2b5fe1e837fa5f5bee98c2 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Nov 2020 10:11:31 +0000 Subject: [PATCH 12/31] Default bar chart data labels to false --- .../src/components/userInterface/temporaryPanelStructure.js | 2 +- packages/standard-components/components.json | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 42410c62f3..aae2320d65 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -591,7 +591,7 @@ export default { key: "dataLabels", control: Checkbox, valueKey: "checked", - defaultValue: true, + defaultValue: false, }, { label: "Animate", diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index b9dab63fe2..30d9409e81 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -563,10 +563,7 @@ }, "width": "number", "horizontal": "bool", - "dataLabels": { - "type": "bool", - "default": true - }, + "dataLabels": "bool", "animate": { "type": "bool", "default": true From 3d84b831e989a5bff047c1dbc6718a84d05ca576 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Nov 2020 11:50:55 +0000 Subject: [PATCH 13/31] Add pie and donut charts --- .../userInterface/temporaryPanelStructure.js | 343 ++++++++---------- packages/standard-components/components.json | 258 +++---------- .../src/Chart/ApexOptionsBuilder.js | 11 + .../src/Chart/DonutChart.svelte | 5 + .../src/Chart/PieChart.svelte | 59 +++ .../standard-components/src/Chart/index.js | 2 + 6 files changed, 269 insertions(+), 409 deletions(-) create mode 100644 packages/standard-components/src/Chart/DonutChart.svelte create mode 100644 packages/standard-components/src/Chart/PieChart.svelte diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index aae2320d65..2f4b10d356 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -423,105 +423,11 @@ export default { icon: "ri-bar-chart-2-line", isCategory: true, children: [ - // { - // name: "Donut", - // _component: "@budibase/standard-components/donut", - // description: "Donut chart", - // icon: "ri-pie-chart-fill", - // properties: { - // settings: [ - // { - // label: "Data", - // key: "datasource", - // control: TableViewSelect, - // }, - // { - // label: "Name Field", - // key: "nameKey", - // dependsOn: "datasource", - // control: TableViewFieldSelect, - // }, - // { - // label: "Value Field", - // key: "valueKey", - // dependsOn: "datasource", - // control: TableViewFieldSelect, - // }, - // { - // label: "Animate Chart", - // key: "isAnimated", - // valueKey: "checked", - // control: Checkbox, - // }, - // { - // label: "Hover Highlight", - // key: "hasHoverAnimation", - // valueKey: "checked", - // control: Checkbox, - // }, - // { - // label: "Keep Last Hover", - // key: "hasLastHoverSliceHighlighted", - // valueKey: "checked", - // control: Checkbox, - // }, - // { - // label: "Colors", - // key: "color", - // control: OptionSelect, - // options: [ - // "britecharts", - // "blueGreen", - // "green", - // "grey", - // "orange", - // "pink", - // "purple", - // "red", - // "teal", - // "yellow", - // ], - // }, - // { - // label: "External Radius", - // key: "externalRadius", - // control: Input, - // }, - // { - // label: "Internal Radius", - // key: "internalRadius", - // control: Input, - // }, - // { - // label: "Radius Offset", - // key: "radiusHoverOffset ", - // control: Input, - // }, - // { - // label: "Show Legend", - // key: "useLegend ", - // valueKey: "checked", - // control: Checkbox, - // }, - // { - // label: "Horizontal Legend", - // key: "horizontalLegend", - // valueKey: "checked", - // control: Checkbox, - // }, - // { - // label: "Legend Width", - // key: "legendWidth", - // control: Input, - // }, - // ], - // }, - // }, { - name: "Bar", + name: "Bar Chart", _component: "@budibase/standard-components/bar", description: "Bar chart", - icon: "ri-bar-chart-fill", + icon: "ri-bar-chart-line", properties: { settings: [ { @@ -610,111 +516,8 @@ export default { ], }, }, - // { - // name: "Grouped Bar", - // _component: "@budibase/standard-components/groupedbar", - // description: "Groupedbar chart", - // icon: "ri-bar-chart-grouped-fill", - // properties: { - // settings: [ - // { - // label: "Data", - // key: "datasource", - // control: TableViewSelect, - // }, - // { - // label: "Name Label", - // key: "nameLabel", - // dependsOn: "datasource", - // control: TableViewFieldSelect, - // }, - // { - // label: "Group Label", - // key: "groupLabel", - // dependsOn: "datasource", - // control: TableViewFieldSelect, - // }, - // { - // label: "Value Label", - // key: "valueLabel", - // dependsOn: "datasource", - // control: TableViewFieldSelect, - // }, - // { - // label: "Color", - // key: "color", - // control: OptionSelect, - // options: [ - // "britecharts", - // "blueGreen", - // "green", - // "grey", - // "orange", - // "pink", - // "purple", - // "red", - // "teal", - // "yellow", - // ], - // }, - // { - // label: "Height", - // key: "height", - // control: Input, - // }, - // { - // label: "Width", - // key: "width", - // control: Input, - // }, - // { - // label: "Aspect Ratio", - // key: "aspectRatio", - // control: Input, - // }, - // { - // label: "Grid", - // key: "grid", - // control: OptionSelect, - // options: ["vertical", "horizontal", "full"], - // }, - // { - // label: "Value Label", - // key: "valueLabel", - // control: Input, - // }, - // { - // label: "Y Ticks", - // key: "yTicks", - // control: Input, - // }, - // { - // label: "Y Tick Text Offset", - // key: "yTickTextOffset", - // control: Input, - // }, - // { - // label: "Is Animated", - // key: "isAnimated", - // valueKey: "checked", - // control: Checkbox, - // }, - // { - // label: "Is Horizontal", - // key: "isHorizontal", - // valueKey: "checked", - // control: Checkbox, - // }, - // { - // label: "Tooltip Title", - // key: "tooltipTitle", - // control: Input, - // }, - // ], - // }, - // }, { - name: "Line", + name: "Line Chart", _component: "@budibase/standard-components/line", description: "Line chart", icon: "ri-line-chart-line", @@ -807,6 +610,146 @@ export default { ], }, }, + { + name: "Pie Chart", + _component: "@budibase/standard-components/pie", + description: "Pie chart", + icon: "ri-pie-chart-line", + properties: { + settings: [ + { + label: "Title", + key: "title", + control: Input, + }, + { + label: "Data", + key: "datasource", + control: TableViewSelect, + }, + { + label: "Label Col.", + key: "labelColumn", + dependsOn: "datasource", + control: TableViewFieldSelect, + }, + { + label: "Data Col.", + key: "valueColumn", + dependsOn: "datasource", + control: TableViewFieldSelect, + }, + // { + // label: "Color", + // key: "color", + // control: Colorpicker, + // defaultValue: "#4285f4", + // }, + { + label: "Width", + key: "width", + control: Input, + }, + { + label: "Height", + key: "height", + control: Input, + defaultValue: "200", + }, + { + label: "Data Labels", + key: "dataLabels", + control: Checkbox, + valueKey: "checked", + defaultValue: false, + }, + { + label: "Animate", + key: "animate", + control: Checkbox, + valueKey: "checked", + defaultValue: true, + }, + { + label: "Legend", + key: "legend", + control: Checkbox, + valueKey: "checked", + defaultValue: true, + }, + ], + }, + }, + { + name: "Donut Chart", + _component: "@budibase/standard-components/donut", + description: "Donut chart", + icon: "ri-donut-chart-line", + properties: { + settings: [ + { + label: "Title", + key: "title", + control: Input, + }, + { + label: "Data", + key: "datasource", + control: TableViewSelect, + }, + { + label: "Label Col.", + key: "labelColumn", + dependsOn: "datasource", + control: TableViewFieldSelect, + }, + { + label: "Data Col.", + key: "valueColumn", + dependsOn: "datasource", + control: TableViewFieldSelect, + }, + // { + // label: "Color", + // key: "color", + // control: Colorpicker, + // defaultValue: "#4285f4", + // }, + { + label: "Width", + key: "width", + control: Input, + }, + { + label: "Height", + key: "height", + control: Input, + defaultValue: "200", + }, + { + label: "Data Labels", + key: "dataLabels", + control: Checkbox, + valueKey: "checked", + defaultValue: false, + }, + { + label: "Animate", + key: "animate", + control: Checkbox, + valueKey: "checked", + defaultValue: true, + }, + { + label: "Legend", + key: "legend", + control: Checkbox, + valueKey: "checked", + defaultValue: true, + }, + ], + }, + }, ], }, { diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index 30d9409e81..db3b4651d6 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -396,155 +396,6 @@ } } }, - "datamap": { - "description": "shiny chart", - "data": true, - "props": { - "table": "tables" - } - }, - "donut": { - "description": "Donut Chart", - "data": true, - "props": { - "datasource": "string", - "data": "string", - "color": "string", - "height": "number", - "width": "number", - "hasFixedHighlightedSlice": "bool", - "hasLastHoverSliceHighlighted": "bool", - "hasHoverAnimation": "bool", - "numberFormat": "string", - "nameKey": "string", - "valueKey": "string", - "isAnimated": "bool", - "externalRadius": "number", - "internalRadius": "number", - "radiusHoverOffset": "number", - "percentageFormat": "string", - "useLegend": "bool", - "legendWidth": "number", - "legendHeight": "number" - } - }, - "sparkline": { - "description": "Sparkline Chart", - "data": true, - "props": { - "table": "string", - "areaGradient": "string", - "height": "number", - "width": "number", - "dateLabel": "string", - "duration": "string", - "isAnimated": "bool", - "lineGradient": "string", - "titleText": "string", - "valueLabel": "string" - } - }, - "stackedbar": { - "description": "Stacked Bar Chart", - "data": true, - "props": { - "datasource": "tables", - "color": "string", - "height": "number", - "width": "number", - "margin": "string", - "aspectRatio": "string", - "betweenBarsPadding": "number", - "grid": "string", - "hasPercentage": "bool", - "hasReversedStacks": "bool", - "isAnimated": "bool", - "isHorizontal": "bool", - "locale": "string", - "nameLabel": "string", - "percentageAxisToMaxRatio": "number", - "stackLabel": "string", - "valueLabel": "string", - "valueLabelFormat": "string", - "xTicks": "number", - "yTicks": "number", - "yAxisLabel": "string", - "yAxisLabelOffset": "number", - "useLegend": "bool" - } - }, - "stackarea": { - "description": "Step Chart", - "data": true, - "props": { - "table": "string", - "color": "string", - "height": "number", - "width": "number", - "margin": "string", - "xAxisLabel": "string", - "xAxisLabelOffset": "string", - "yAxisLabel": "string", - "yAxisLabelOffset": "string", - "areaCurve": "number", - "areaOpacity": "number", - "aspectRatio": "number", - "dateLabel": "string", - "grid": "string", - "isAnimated": "bool", - "keyLabel": "string", - "locale": "string", - "tooltipThreshold": "number", - "topicsOrder": "string", - "valueLabel": "string", - "xAxisCustomFormat": "string", - "xAxisFormat": "string", - "xAxisScale": "string", - "xAxisValueType": "string", - "yTicks": "number", - "xTicks": "number", - "yAxisBaseline": "string", - "useLegend": "bool" - } - }, - "step": { - "description": "Step Chart", - "data": true, - "props": { - "table": "string", - "height": "number", - "width": "number", - "margin": "string", - "xAxisLabel": "string", - "xAxisLabelOffset": "string", - "yAxisLabel": "string", - "yAxisLabelOffset": "string", - "yTicks": "string" - } - }, - "scatterplot": { - "description": "Scatterplot Chart", - "data": true, - "props": { - "table": "string", - "color": "string", - "height": "number", - "width": "number", - "aspectRatio": "string", - "circleOpacity": "string", - "grid": "string", - "hasCrossHairs": "bool", - "isAnimated": "bool", - "maxCircleArea": "number", - "xAxisLabel": "string", - "xAxisLabelOffset": "string", - "xTicks": "string", - "yAxisFormat": "string", - "yAxisLabel": "string", - "yAxisLabelOffset": "string", - "yTicks": "string" - } - }, "bar": { "description": "Bar Chart", "data": true, @@ -614,74 +465,63 @@ "type": "bool", "default": true }, + "legend": "bool" + } + }, + "pie": { + "description": "Pie Chart", + "data": true, + "props": { + "title": "string", + "datasource": "tables", + "labelColumn": "string", + "valueColumn": "string", + "color": { + "type": "string", + "default": "#4285f4" + }, + "height": { + "type": "number", + "default": "200" + }, + "width": "number", + "dataLabels": "bool", + "animate": { + "type": "bool", + "default": true + }, "legend": { "type": "bool", - "default": false + "default": true } } }, - "brush": { - "description": "brush chart", - "data": true, - "props": { - "table": "string", - "gradient": "string", - "height": "number", - "width": "number", - "margin": "string", - "dateRange": "string", - "locale": "string", - "roundingTimeInterval": "string", - "xAxisFormat": "string", - "xTicks": "number", - "xAxisCustomFormat": "string" - } - }, - "heatmap": { - "description": "Heatmap chart", - "data": true, - "props": { - "table": "string", - "color": "string", - "height": "number", - "width": "number", - "useLegend": "bool", - "yAxisLabel": "string", - "boxSize": "number" - } - }, - "groupedbar": { - "description": "Groupedbar chart", + "donut": { + "description": "Donut Chart", "data": true, "props": { + "title": "string", "datasource": "tables", - "nameLabel": "string", - "valueLabel": "string", - "color": "string", - "height": "string", - "width": "string", - "margin": "string", - "grid": "string", - "groupLabel": "string", - "isAnimated": "bool", - "isHorizontal": "bool", - "yTicks": "string", - "useLegend": "bool", - "tooltipTitle": "string" - } - }, - "bullet": { - "description": "Bullet chart", - "data": true, - "props": { - "table": "string", - "color": "string", - "customSubtitle": "string", - "customTitle": "string", - "numberFormat": "string", - "paddingBetweenAxisAndChart": "number", - "height": "number", - "width": "number" + "labelColumn": "string", + "valueColumn": "string", + "color": { + "type": "string", + "default": "#4285f4" + }, + "height": { + "type": "number", + "default": "200" + }, + "width": "number", + "dataLabels": "bool", + "animate": { + "type": "bool", + "default": true + }, + "legend": { + "type": "bool", + "default": true + } } }, "datepicker": { diff --git a/packages/standard-components/src/Chart/ApexOptionsBuilder.js b/packages/standard-components/src/Chart/ApexOptionsBuilder.js index 9df273d7d7..c7f28e817d 100644 --- a/packages/standard-components/src/Chart/ApexOptionsBuilder.js +++ b/packages/standard-components/src/Chart/ApexOptionsBuilder.js @@ -13,6 +13,9 @@ export class ApexOptionsBuilder { toolbar: { show: false, }, + zoom: { + enabled: false, + }, }, } @@ -105,7 +108,15 @@ export class ApexOptionsBuilder { return this.setOption(["legend", "show"], legend) } + legendPosition(position) { + return this.setOption(["legend", "position"], position) + } + stacked(stacked) { return this.setOption(["chart", "stacked"], stacked) } + + labels(labels) { + return this.setOption(["labels"], labels) + } } diff --git a/packages/standard-components/src/Chart/DonutChart.svelte b/packages/standard-components/src/Chart/DonutChart.svelte new file mode 100644 index 0000000000..721a09053a --- /dev/null +++ b/packages/standard-components/src/Chart/DonutChart.svelte @@ -0,0 +1,5 @@ + + + diff --git a/packages/standard-components/src/Chart/PieChart.svelte b/packages/standard-components/src/Chart/PieChart.svelte new file mode 100644 index 0000000000..9bcc490817 --- /dev/null +++ b/packages/standard-components/src/Chart/PieChart.svelte @@ -0,0 +1,59 @@ + + +
diff --git a/packages/standard-components/src/Chart/index.js b/packages/standard-components/src/Chart/index.js index 5a9e94f00d..047fe60965 100644 --- a/packages/standard-components/src/Chart/index.js +++ b/packages/standard-components/src/Chart/index.js @@ -1,2 +1,4 @@ export { default as bar } from "./BarChart.svelte" export { default as line } from "./LineChart.svelte" +export { default as pie } from "./PieChart.svelte" +export { default as donut } from "./DonutChart.svelte" From 91ef7fd0a77f7831b3a5e4e817f61a7ac74965c1 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Nov 2020 14:32:21 +0000 Subject: [PATCH 14/31] Add area chart and unit formatting --- .../userInterface/temporaryPanelStructure.js | 122 ++++++++++++++++++ packages/standard-components/components.json | 61 ++++++++- .../src/Chart/ApexOptionsBuilder.js | 17 +++ .../src/Chart/AreaChart.svelte | 5 + .../src/Chart/LineChart.svelte | 14 +- .../standard-components/src/Chart/index.js | 1 + 6 files changed, 216 insertions(+), 4 deletions(-) create mode 100644 packages/standard-components/src/Chart/AreaChart.svelte diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 2f4b10d356..55bd19ab64 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -545,6 +545,13 @@ export default { dependsOn: "datasource", control: MultiTableViewFieldSelect, }, + { + label: "Format", + key: "yAxisUnits", + control: OptionSelect, + options: ["Default", "Thousands", "Millions"], + defaultValue: "Default", + }, { label: "Y Axis Label", key: "yAxisLabel", @@ -610,6 +617,121 @@ export default { ], }, }, + { + name: "Area Chart", + _component: "@budibase/standard-components/area", + description: "Line chart", + icon: "ri-line-chart-fill", + properties: { + settings: [ + { + label: "Title", + key: "title", + control: Input, + }, + { + label: "Data", + key: "datasource", + control: TableViewSelect, + }, + { + label: "Label Col.", + key: "labelColumn", + dependsOn: "datasource", + control: TableViewFieldSelect, + }, + { + label: "Data Cols.", + key: "valueColumns", + dependsOn: "datasource", + control: MultiTableViewFieldSelect, + }, + { + label: "Format", + key: "yAxisUnits", + control: OptionSelect, + options: ["Default", "Thousands", "Millions"], + defaultValue: "Default", + }, + { + label: "Y Label", + key: "yAxisLabel", + control: Input, + }, + { + label: "X Label", + key: "xAxisLabel", + control: Input, + }, + // { + // label: "Color", + // key: "color", + // control: Colorpicker, + // defaultValue: "#4285f4", + // }, + { + label: "Width", + key: "width", + control: Input, + }, + { + label: "Height", + key: "height", + control: Input, + defaultValue: "400", + }, + { + label: "Curve", + key: "curve", + control: OptionSelect, + options: ["Smooth", "Straight", "Stepline"], + defaultValue: "Smooth", + }, + { + label: "Data Labels", + key: "dataLabels", + control: Checkbox, + valueKey: "checked", + defaultValue: false, + }, + { + label: "Animate", + key: "animate", + control: Checkbox, + valueKey: "checked", + defaultValue: true, + }, + { + label: "Fill", + key: "fill", + control: Checkbox, + valueKey: "checked", + defaultValue: true, + }, + { + label: "Legend", + key: "legend", + control: Checkbox, + valueKey: "checked", + defaultValue: false, + }, + { + label: "Stacked", + key: "stacked", + control: Checkbox, + valueKey: "checked", + defaultValue: false, + }, + { + label: "Gradient", + key: "gradient", + control: Checkbox, + valueKey: "checked", + defaultValue: false, + }, + ], + }, + }, { name: "Pie Chart", _component: "@budibase/standard-components/pie", diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index db3b4651d6..59012fda01 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -465,7 +465,66 @@ "type": "bool", "default": true }, - "legend": "bool" + "legend": "bool", + "yAxisUnits": { + "type": "options", + "default": "Default", + "options": [ + "Default", "Thousands", "Millions" + ] + } + } + }, + "area": { + "description": "Area Chart", + "data": true, + "props": { + "title": "string", + "datasource": "tables", + "labelColumn": "string", + "valueColumns": "string", + "color": { + "type": "string", + "default": "#4285f4" + }, + "height": { + "type": "number", + "default": "400" + }, + "width": "number", + "dataLabels": { + "type": "bool", + "default": false + }, + "animate": { + "type": "bool", + "default": true + }, + "xAxisLabel": "string", + "yAxisLabel": "string", + "curve": { + "type": "options", + "options": [ + "Smooth", + "Straight", + "Stepline" + ], + "default": "Smooth" + }, + "fill": { + "type": "bool", + "default": true + }, + "legend": "bool", + "stacked": "bool", + "gradient": "bool", + "yAxisUnits": { + "type": "options", + "default": "Default", + "options": [ + "Default", "Thousands", "Millions" + ] + } } }, "pie": { diff --git a/packages/standard-components/src/Chart/ApexOptionsBuilder.js b/packages/standard-components/src/Chart/ApexOptionsBuilder.js index c7f28e817d..4d5067ab06 100644 --- a/packages/standard-components/src/Chart/ApexOptionsBuilder.js +++ b/packages/standard-components/src/Chart/ApexOptionsBuilder.js @@ -1,4 +1,9 @@ export class ApexOptionsBuilder { + formatters = { + ["Default"]: val => Math.round(val * 100) / 100, + ["Thousands"]: val => `${Math.round(val / 1000)}K`, + ["Millions"]: val => `${Math.round(val / 1000000)}M`, + } options = { series: [], legend: { @@ -17,6 +22,11 @@ export class ApexOptionsBuilder { enabled: false, }, }, + yaxis: { + labels: { + formatter: this.formatters.Default, + }, + }, } setOption(path, value) { @@ -119,4 +129,11 @@ export class ApexOptionsBuilder { labels(labels) { return this.setOption(["labels"], labels) } + + yUnits(units) { + return this.setOption( + ["yaxis", "labels", "formatter"], + this.formatters[units || "Default"] + ) + } } diff --git a/packages/standard-components/src/Chart/AreaChart.svelte b/packages/standard-components/src/Chart/AreaChart.svelte new file mode 100644 index 0000000000..dc80b2b9da --- /dev/null +++ b/packages/standard-components/src/Chart/AreaChart.svelte @@ -0,0 +1,5 @@ + + + diff --git a/packages/standard-components/src/Chart/LineChart.svelte b/packages/standard-components/src/Chart/LineChart.svelte index be5d3a94e4..f9dd334dc3 100644 --- a/packages/standard-components/src/Chart/LineChart.svelte +++ b/packages/standard-components/src/Chart/LineChart.svelte @@ -5,6 +5,7 @@ import { isEmpty, sortBy } from "lodash/fp" import { ApexOptionsBuilder } from "./ApexOptionsBuilder" + // Common props export let title export let datasource export let labelColumn @@ -17,8 +18,13 @@ export let animate export let dataLabels export let curve - export let fill export let legend + export let yAxisUnits + + // Area specific props + export let area + export let stacked + export let gradient let data = [] $: options = getChartOptions(data) @@ -35,7 +41,7 @@ // Initialise default chart let builder = new ApexOptionsBuilder() .title(title) - .type(fill ? "area" : "line") + .type(area ? "area" : "line") // .color(color) .width(width) .height(height) @@ -44,8 +50,10 @@ .dataLabels(dataLabels) .animate(animate) .curve(curve.toLowerCase()) - .gradient(fill) + .gradient(gradient) + .stacked(stacked) .legend(legend) + .yUnits(yAxisUnits) // Add data if valid datasource if (rows && rows.length) { diff --git a/packages/standard-components/src/Chart/index.js b/packages/standard-components/src/Chart/index.js index 047fe60965..dc859535f7 100644 --- a/packages/standard-components/src/Chart/index.js +++ b/packages/standard-components/src/Chart/index.js @@ -2,3 +2,4 @@ export { default as bar } from "./BarChart.svelte" export { default as line } from "./LineChart.svelte" export { default as pie } from "./PieChart.svelte" export { default as donut } from "./DonutChart.svelte" +export { default as area } from "./AreaChart.svelte" From c98e59d7f6c73824cae759e20d7c194be3d46503 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Tue, 3 Nov 2020 16:14:57 +0000 Subject: [PATCH 15/31] Fix legends not being centered and use common chart component --- .../standard-components/src/Chart/ApexChart.svelte | 14 ++++++++++++++ .../standard-components/src/Chart/BarChart.svelte | 4 ++-- .../standard-components/src/Chart/LineChart.svelte | 4 ++-- .../standard-components/src/Chart/PieChart.svelte | 3 ++- 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 packages/standard-components/src/Chart/ApexChart.svelte diff --git a/packages/standard-components/src/Chart/ApexChart.svelte b/packages/standard-components/src/Chart/ApexChart.svelte new file mode 100644 index 0000000000..91eed23acd --- /dev/null +++ b/packages/standard-components/src/Chart/ApexChart.svelte @@ -0,0 +1,14 @@ + + +
+ + diff --git a/packages/standard-components/src/Chart/BarChart.svelte b/packages/standard-components/src/Chart/BarChart.svelte index de51316ed4..40774956fd 100644 --- a/packages/standard-components/src/Chart/BarChart.svelte +++ b/packages/standard-components/src/Chart/BarChart.svelte @@ -1,9 +1,9 @@ -
+ diff --git a/packages/standard-components/src/Chart/LineChart.svelte b/packages/standard-components/src/Chart/LineChart.svelte index f9dd334dc3..5a1b068728 100644 --- a/packages/standard-components/src/Chart/LineChart.svelte +++ b/packages/standard-components/src/Chart/LineChart.svelte @@ -1,9 +1,9 @@ -
+ diff --git a/packages/standard-components/src/Chart/PieChart.svelte b/packages/standard-components/src/Chart/PieChart.svelte index 9bcc490817..4382cf220f 100644 --- a/packages/standard-components/src/Chart/PieChart.svelte +++ b/packages/standard-components/src/Chart/PieChart.svelte @@ -4,6 +4,7 @@ import fetchData from "../fetchData" import { isEmpty, sortBy } from "lodash/fp" import { ApexOptionsBuilder } from "./ApexOptionsBuilder" + import ApexChart from "./ApexChart.svelte" export let title export let datasource @@ -56,4 +57,4 @@ } -
+ From 6cddc36729b9a199487c5e53886b26474b2c38b1 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 4 Nov 2020 12:38:52 +0000 Subject: [PATCH 16/31] Fix beta warning overlap --- packages/builder/src/pages/[application]/design/_layout.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/pages/[application]/design/_layout.svelte b/packages/builder/src/pages/[application]/design/_layout.svelte index 4d84c6d29a..1ff8dadd5f 100644 --- a/packages/builder/src/pages/[application]/design/_layout.svelte +++ b/packages/builder/src/pages/[application]/design/_layout.svelte @@ -69,7 +69,7 @@ display: flex; flex-direction: column; gap: var(--spacing-l); - padding: var(--spacing-l) var(--spacing-xl); + padding: var(--spacing-l) var(--spacing-xl) 60px var(--spacing-xl); overflow-y: auto; } From 0c48a2058147ec45d4bd5e564076eae49c24dfcb Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 4 Nov 2020 12:43:56 +0000 Subject: [PATCH 17/31] Add support for dates and increase robustness --- .../userInterface/temporaryPanelStructure.js | 13 ++-- packages/standard-components/components.json | 10 ++- .../src/Chart/ApexChart.svelte | 6 +- .../src/Chart/ApexOptionsBuilder.js | 6 ++ .../src/Chart/BarChart.svelte | 77 ++++++++++++------- .../src/Chart/LineChart.svelte | 70 +++++++++++------ packages/standard-components/src/fetchData.js | 18 ++--- 7 files changed, 132 insertions(+), 68 deletions(-) diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 55bd19ab64..70211fb6a5 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -452,6 +452,13 @@ export default { dependsOn: "datasource", control: MultiTableViewFieldSelect, }, + { + label: "Format", + key: "yAxisUnits", + control: OptionSelect, + options: ["Default", "Thousands", "Millions"], + defaultValue: "Default", + }, { label: "Y Axis Label", key: "yAxisLabel", @@ -486,12 +493,6 @@ export default { valueKey: "checked", defaultValue: false, }, - { - label: "Horizontal", - key: "horizontal", - control: Checkbox, - valueKey: "checked", - }, { label: "Data Labels", key: "dataLabels", diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index 59012fda01..f0b23d263a 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -413,7 +413,6 @@ "default": "400" }, "width": "number", - "horizontal": "bool", "dataLabels": "bool", "animate": { "type": "bool", @@ -422,7 +421,14 @@ "xAxisLabel": "string", "yAxisLabel": "string", "legend": "bool", - "stacked": "bool" + "stacked": "bool", + "yAxisUnits": { + "type": "options", + "default": "Default", + "options": [ + "Default", "Thousands", "Millions" + ] + } } }, "line": { diff --git a/packages/standard-components/src/Chart/ApexChart.svelte b/packages/standard-components/src/Chart/ApexChart.svelte index 91eed23acd..c83c7c47c2 100644 --- a/packages/standard-components/src/Chart/ApexChart.svelte +++ b/packages/standard-components/src/Chart/ApexChart.svelte @@ -4,7 +4,11 @@ export let options -
+{#if options} +
+{:else} +
Invalid chart options
+{/if} From 732685ec602773f1792315c31d3c47aba4950103 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 5 Nov 2020 13:27:29 +0000 Subject: [PATCH 30/31] Ensure candlestick chart works with either our own date formats as well as timestamps --- packages/standard-components/src/Chart/CandleStickChart.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/standard-components/src/Chart/CandleStickChart.svelte b/packages/standard-components/src/Chart/CandleStickChart.svelte index 7854b495f8..c034855e5e 100644 --- a/packages/standard-components/src/Chart/CandleStickChart.svelte +++ b/packages/standard-components/src/Chart/CandleStickChart.svelte @@ -59,8 +59,9 @@ .xType("datetime") // Add data + const parseDate = d => (isNaN(d) ? Date.parse(d).valueOf() : parseInt(d)) const chartData = data.map(row => ({ - x: row[dateColumn], + x: parseDate(row[dateColumn]), y: [row[openColumn], row[highColumn], row[lowColumn], row[closeColumn]], })) builder = builder.series([{ data: chartData }]) From 31c083d5baf0874037ebd1669c0f77a9d057a805 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 5 Nov 2020 13:37:28 +0000 Subject: [PATCH 31/31] Add colour palette options for charts --- .../userInterface/temporaryPanelStructure.js | 90 +++++++++++++++++++ packages/standard-components/components.json | 80 +++++++++++++++++ .../src/Chart/ApexOptionsBuilder.js | 7 ++ .../src/Chart/BarChart.svelte | 2 + .../src/Chart/LineChart.svelte | 2 + .../src/Chart/PieChart.svelte | 2 + 6 files changed, 183 insertions(+) diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 1239027f9d..ef88c93001 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -480,6 +480,24 @@ export default { control: Input, defaultValue: "400", }, + { + label: "Colours", + key: "palette", + control: OptionSelect, + defaultValue: "Palette 1", + options: [ + "Palette 1", + "Palette 2", + "Palette 3", + "Palette 4", + "Palette 5", + "Palette 6", + "Palette 7", + "Palette 8", + "Palette 9", + "Palette 10", + ], + }, { label: "Stacked", key: "stacked", @@ -575,6 +593,24 @@ export default { options: ["Smooth", "Straight", "Stepline"], defaultValue: "Smooth", }, + { + label: "Colours", + key: "palette", + control: OptionSelect, + defaultValue: "Palette 1", + options: [ + "Palette 1", + "Palette 2", + "Palette 3", + "Palette 4", + "Palette 5", + "Palette 6", + "Palette 7", + "Palette 8", + "Palette 9", + "Palette 10", + ], + }, { label: "Data Labels", key: "dataLabels", @@ -663,6 +699,24 @@ export default { options: ["Smooth", "Straight", "Stepline"], defaultValue: "Smooth", }, + { + label: "Colours", + key: "palette", + control: OptionSelect, + defaultValue: "Palette 1", + options: [ + "Palette 1", + "Palette 2", + "Palette 3", + "Palette 4", + "Palette 5", + "Palette 6", + "Palette 7", + "Palette 8", + "Palette 9", + "Palette 10", + ], + }, { label: "Data Labels", key: "dataLabels", @@ -741,6 +795,24 @@ export default { control: Input, defaultValue: "200", }, + { + label: "Colours", + key: "palette", + control: OptionSelect, + defaultValue: "Palette 1", + options: [ + "Palette 1", + "Palette 2", + "Palette 3", + "Palette 4", + "Palette 5", + "Palette 6", + "Palette 7", + "Palette 8", + "Palette 9", + "Palette 10", + ], + }, { label: "Data Labels", key: "dataLabels", @@ -805,6 +877,24 @@ export default { control: Input, defaultValue: "200", }, + { + label: "Colours", + key: "palette", + control: OptionSelect, + defaultValue: "Palette 1", + options: [ + "Palette 1", + "Palette 2", + "Palette 3", + "Palette 4", + "Palette 5", + "Palette 6", + "Palette 7", + "Palette 8", + "Palette 9", + "Palette 10", + ], + }, { label: "Data Labels", key: "dataLabels", diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index 6853ab7ffd..5b258c3c17 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -424,6 +424,22 @@ "options": [ "Default", "Thousands", "Millions" ] + }, + "palette": { + "type": "options", + "default": "Palette 1", + "options": [ + "Palette 1", + "Palette 2", + "Palette 3", + "Palette 4", + "Palette 5", + "Palette 6", + "Palette 7", + "Palette 8", + "Palette 9", + "Palette 10" + ] } } }, @@ -466,6 +482,22 @@ "options": [ "Default", "Thousands", "Millions" ] + }, + "palette": { + "type": "options", + "default": "Palette 1", + "options": [ + "Palette 1", + "Palette 2", + "Palette 3", + "Palette 4", + "Palette 5", + "Palette 6", + "Palette 7", + "Palette 8", + "Palette 9", + "Palette 10" + ] } } }, @@ -513,6 +545,22 @@ "options": [ "Default", "Thousands", "Millions" ] + }, + "palette": { + "type": "options", + "default": "Palette 1", + "options": [ + "Palette 1", + "Palette 2", + "Palette 3", + "Palette 4", + "Palette 5", + "Palette 6", + "Palette 7", + "Palette 8", + "Palette 9", + "Palette 10" + ] } } }, @@ -537,6 +585,22 @@ "legend": { "type": "bool", "default": true + }, + "palette": { + "type": "options", + "default": "Palette 1", + "options": [ + "Palette 1", + "Palette 2", + "Palette 3", + "Palette 4", + "Palette 5", + "Palette 6", + "Palette 7", + "Palette 8", + "Palette 9", + "Palette 10" + ] } } }, @@ -561,6 +625,22 @@ "legend": { "type": "bool", "default": true + }, + "palette": { + "type": "options", + "default": "Palette 1", + "options": [ + "Palette 1", + "Palette 2", + "Palette 3", + "Palette 4", + "Palette 5", + "Palette 6", + "Palette 7", + "Palette 8", + "Palette 9", + "Palette 10" + ] } } }, diff --git a/packages/standard-components/src/Chart/ApexOptionsBuilder.js b/packages/standard-components/src/Chart/ApexOptionsBuilder.js index 93b0bdb685..5c2ae1eb05 100644 --- a/packages/standard-components/src/Chart/ApexOptionsBuilder.js +++ b/packages/standard-components/src/Chart/ApexOptionsBuilder.js @@ -144,4 +144,11 @@ export class ApexOptionsBuilder { yTooltip(yTooltip) { return this.setOption(["yaxis", "tooltip", "enabled"], yTooltip) } + + palette(palette) { + return this.setOption( + ["theme", "palette"], + palette.toLowerCase().replace(/[\W]/g, "") + ) + } } diff --git a/packages/standard-components/src/Chart/BarChart.svelte b/packages/standard-components/src/Chart/BarChart.svelte index 0946204e9d..9fdc649dfa 100644 --- a/packages/standard-components/src/Chart/BarChart.svelte +++ b/packages/standard-components/src/Chart/BarChart.svelte @@ -27,6 +27,7 @@ export let legend export let stacked export let yAxisUnits + export let palette const store = _bb.store let options @@ -66,6 +67,7 @@ .legend(legend) .stacked(stacked) .yUnits(yAxisUnits) + .palette(palette) // Add data let useDates = false diff --git a/packages/standard-components/src/Chart/LineChart.svelte b/packages/standard-components/src/Chart/LineChart.svelte index db14b5c337..866a672491 100644 --- a/packages/standard-components/src/Chart/LineChart.svelte +++ b/packages/standard-components/src/Chart/LineChart.svelte @@ -21,6 +21,7 @@ export let curve export let legend export let yAxisUnits + export let palette // Area specific props export let area @@ -67,6 +68,7 @@ .stacked(stacked) .legend(legend) .yUnits(yAxisUnits) + .palette(palette) // Add data let useDates = false diff --git a/packages/standard-components/src/Chart/PieChart.svelte b/packages/standard-components/src/Chart/PieChart.svelte index 9fec69b1bd..75cf1d5c6a 100644 --- a/packages/standard-components/src/Chart/PieChart.svelte +++ b/packages/standard-components/src/Chart/PieChart.svelte @@ -17,6 +17,7 @@ export let animate export let legend export let donut + export let palette const store = _bb.store let options @@ -50,6 +51,7 @@ .animate(animate) .legend(legend) .legendPosition("right") + .palette(palette) // Add data if valid datasource const series = data.map(row => parseFloat(row[valueColumn]))