From 5b51cbad9b2b2a17d12d122f2bb26485f448f9a8 Mon Sep 17 00:00:00 2001 From: cmack Date: Wed, 29 Jul 2020 16:35:44 +0100 Subject: [PATCH] WIP: Bar, Brush, Bullet, Donut and Line --- .../userInterface/temporaryPanelStructure.js | 195 +++++++++++++++++- packages/standard-components/components.json | 43 +++- .../standard-components/src/Chart/Bar.svelte | 50 ++++- .../src/Chart/Brush.svelte | 94 +++++++++ .../src/Chart/Bullet.svelte | 79 +++++++ .../src/Chart/Donut.svelte | 127 ++++++++++-- .../standard-components/src/Chart/Line.svelte | 157 +++++++++++--- .../standard-components/src/Chart/Temp.svelte | 39 ++++ .../standard-components/src/Chart/index.js | 3 + .../standard-components/src/Chart/utils.js | 19 ++ 10 files changed, 744 insertions(+), 62 deletions(-) create mode 100644 packages/standard-components/src/Chart/Temp.svelte create mode 100644 packages/standard-components/src/Chart/utils.js diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 5bbe7eb1cf..57b474cbb0 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -393,7 +393,7 @@ export default { }, properties: { design: { - ...all + ...all, }, settings: [ { @@ -414,6 +414,12 @@ export default { valueKey: "checked", control: Checkbox, }, + { + label: "Has Hover", + key: "hasHoverAnimation", + valueKey: "checked", + control: Checkbox, + }, { label: "Colors", key: "color", @@ -459,6 +465,7 @@ export default { { label: "Show Legend", key: "useLegend ", + valueKey: "checked", control: Checkbox, }, ], @@ -561,8 +568,13 @@ export default { valueKey: "checked", }, { - label: "Label Offset", - key: "labelOffset", + label: "X Axis Label Offset", + key: "xAxisLabelOffset", + control: Input, + }, + { + label: "Y Axis Label Offset", + key: "yAxisLabelOffset", control: Input, }, { @@ -598,6 +610,172 @@ export default { ], }, }, + { + name: "Brush", + _component: "@budibase/standard-components/brush", + description: "Brush chart", + icon: "ri-bar-chart-fill", + presetProps: { + data: [ + { + value: 1, + date: "2011-01-06T00:00:00Z", + }, + { + value: 2, + date: "2011-01-07T00:00:00Z", + }, + ], + }, + properties: { + settings: [ + { + label: "Gradient", + key: "gradient", + control: OptionSelect, + options: [ + { value: "", label: "None" }, + { value: "bluePurple", label: "Blue Purple" }, + { value: "greenBlue", label: "Green Blue" }, + { value: "orangePink", label: "Orange Pink" }, + ], + }, + { + label: "Height", + key: "height", + control: Input, + }, + { + label: "Width", + key: "width", + control: Input, + }, + { + label: "Date Range", + key: "dateRange", + control: Input, + }, + { + label: "Locale", + key: "locale", + control: Input, + }, + { + label: "Time Interval", + key: "roundingTimeInterval", + control: OptionSelect, + options: [ + "timeDay", + "timeMillisecond", + "utcMillisecond", + "timeSecond", + "utcSecond", + "timeMinute", + "utcMinute", + "timeHour", + "utcHour", + "utcDay", + "timeWeek", + "utcWeek", + "timeSunday", + "utcSunday", + "timeMonday", + "utcMonday", + "timeTuesday", + "utcTuesday", + "timeWednesday", + "utcWednesday", + "timeThursday", + "utcThursday", + "timeFriday", + "utcFriday", + "timeSaturday", + "utcSaturday", + "timeMonth", + "utcMonth", + "timeYear", + "utcYear", + ], + }, + { + label: "X Axis Format", + key: "xAxisFormat", + control: OptionSelect, + options: [ + "day-month", + "minute-hour", + "hour-daymonth", + "month-year", + "custom", + ], + }, + { + label: "X Ticks", + key: "xTicks", + control: Input, + }, + ], + }, + }, + { + name: "Bullet", + _component: "@budibase/standard-components/bullet", + description: "Bullet chart", + icon: "ri-bar-chart-fill", + presetProps: { + data: { + ranges: [130, 160, 250], + measures: [150, 180], + markers: [175], + }, + }, + properties: { + settings: [ + { + label: "Color", + key: "color", + control: OptionSelect, + options: [ + "britecharts", + "blueGreen", + "green", + "grey", + "orange", + "pink", + "purple", + "red", + "teal", + "yellow", + ], + }, + { + label: "Title", + key: "title", + control: Input, + }, + { + label: "Subtitle", + key: "subtitle", + control: Input, + }, + { + label: "Axis Padding", + key: "paddingBetweenAxisAndChart", + control: Input, + }, + { + label: "Height", + key: "height", + control: Input, + }, + { + label: "Width", + key: "width", + control: Input, + }, + ], + }, + }, { name: "Line", _component: "@budibase/standard-components/line", @@ -684,6 +862,12 @@ export default { "yellow", ], }, + { + label: "X Axis Value Type", + key: "xAxisValueType", + control: OptionSelect, + options: ["date", "number"], + }, { label: "Grid", key: "grid", @@ -782,6 +966,11 @@ export default { key: "xAxisCustomFormat", control: Input, }, + { + label: "X Axis Label", + key: "xAxisLabel", + control: Input, + }, ], }, }, diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index b79873e3a6..a45edf5edd 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -261,11 +261,14 @@ "width": "number", "hasFixedHighlightedSlice": "bool", "hasLastHoverSliceHighlighted": "bool", + "hasHoverAnimation": "bool", + "numberFormat": "string", "isAnimated": "bool", "externalRadius": "number", "internalRadius": "number", "radiusHoverOffset": "number", - "useLegend": "bool" + "useLegend": "bool", + "percentageFormat": "string" } }, "bar": { @@ -281,7 +284,8 @@ "width": "number", "isAnimated": "bool", "isHorizontal": "bool", - "labelOffset": "number", + "xAxisLabelOffset": "number", + "yAxisLabelOffset": "number", "labelNumberFormat": "number", "labelSize": "number", "locale": "string", @@ -289,7 +293,9 @@ "numberLabel": "string", "xAxisLabel": "string", "yAxisLabel": "string", - "useLegend": "bool" + "useLegend": "bool", + "xTicks": "number", + "yTicks": "number" } }, "line": { @@ -310,13 +316,42 @@ "shouldShowAllDataPoints": "bool", "topicLabel": "string", "valueLabel": "string", - "xAxisLabel": "string", "xAxisValueType": "string", "xAxisScale": "string", "xAxisFormat": "string", + "xAxisCustomFormat": "string", + "xAxisLabel": "string" + } + }, + "brush":{ + "description": "brush chart", + "data": true, + "props": { + "gradient": "string", + "height": "number", + "width": "number", + "margin": "string", + "dateRange": "string", + "locale": "string", + "roundingTimeInterval": "string", + "xAxisFormat": "string", + "xTicks": "number", "xAxisCustomFormat": "string" } }, + "bullet": { + "description": "Bullet chart", + "data": true, + "props": { + "color": "string", + "customSubtitle": "string", + "customTitle": "string", + "numberFormat": "string", + "paddingBetweenAxisAndChart": "number", + "height": "number", + "width": "number" + } + }, "datachart": { "description": "shiny chart", "data": true, diff --git a/packages/standard-components/src/Chart/Bar.svelte b/packages/standard-components/src/Chart/Bar.svelte index 2bea43cb14..ea08baea60 100644 --- a/packages/standard-components/src/Chart/Bar.svelte +++ b/packages/standard-components/src/Chart/Bar.svelte @@ -34,28 +34,35 @@ export let gradient = null export let color = "britecharts" export let enableLabels = true + export let hasPercentage = null export let hasSingleBarHighlight = true + export let highlightBarFunction = null export let height = 200 export let width = 300 + export let labelsMargin = null export let isAnimated = true export let isHorizontal = true - export let labelOffset = null + export let xAxisLabelOffset = null + export let yAxisLabelOffset = null export let labelsNumberFormat = null - export let labelSize = null export let locale = null + export let valueLabel = null export let nameLabel = null export let numberFormat = null + export let labelsSize = null + export let xTicks = null + export let yTicks = null + export let percentageAxisToMaxRatio = null export let useLegend = true onMount(() => { - //call charts props in here if (chartElement) { chartContainer = select(`.${chartClass}`) bindChartUIProps() bindChartEvents() - bindChartTooltip() chartContainer.datum(data).call(chart) + bindChartTooltip() } }) @@ -73,17 +80,26 @@ chart.yAxisLabel(yAxisLabel) } if (betweenBarsPadding) { - chart.betweenBarsPadding(betweenBarsPadding) + chart.betweenBarsPadding(Number(betweenBarsPadding)) } if (enableLabels) { chart.enableLabels(enableLabels) } + if (hasPercentage) { + chart.hasPercentage(hasPercentage) + } if (hasSingleBarHighlight) { chart.hasSingleBarHighlight(hasSingleBarHighlight) } + if (labelsMargin) { + chart.labelsMargin(labelsMargin) + } if (height) { chart.height(height) } + if (highlightBarFunction) { + chart.highlightBarFunction(highlightBarFunction) + } if (width) { chart.width(width) } @@ -93,14 +109,17 @@ if (isHorizontal) { chart.isHorizontal(isHorizontal) } - if (labelOffset) { - chart.labelOffset(labelOffset) + if (yAxisLabelOffset) { + chart.yAxisLabelOffset(Number(yAxisLabelOffset)) + } + if (xAxisLabelOffset) { + chart.xAxisLabelOffset(Number(xAxisLabelOffset)) } if (labelsNumberFormat) { chart.labelsNumberFormat(labelsNumberFormat) } - if (labelSize) { - chart.labelSize(labelSize) + if (valueLabel) { + chart.valueLabel(valueLabel) } if (locale) { chart.locale(locale) @@ -111,6 +130,18 @@ if (numberFormat) { chart.numberFormat(numberFormat) } + if (labelsSize) { + chart.labelsSize(labelsSize) + } + if (xTicks) { + chart.xTicks(xTicks) + } + if (yTicks) { + chart.yTicks(yTicks) + } + if (percentageAxisToMaxRatio) { + chart.percentageAxisToMaxRatio(percentageAxisToMaxRatio) + } } function bindChartEvents() { @@ -130,7 +161,6 @@ function bindChartTooltip() { tooltip = britecharts.miniTooltip() - debugger tooltipContainer = select(`.${chartClass} .metadata-group`) tooltipContainer.datum([]).call(tooltip) } diff --git a/packages/standard-components/src/Chart/Brush.svelte b/packages/standard-components/src/Chart/Brush.svelte index e69de29bb2..0dbf0b6171 100644 --- a/packages/standard-components/src/Chart/Brush.svelte +++ b/packages/standard-components/src/Chart/Brush.svelte @@ -0,0 +1,94 @@ + + +
diff --git a/packages/standard-components/src/Chart/Bullet.svelte b/packages/standard-components/src/Chart/Bullet.svelte index e69de29bb2..1356eea3a7 100644 --- a/packages/standard-components/src/Chart/Bullet.svelte +++ b/packages/standard-components/src/Chart/Bullet.svelte @@ -0,0 +1,79 @@ + + +
diff --git a/packages/standard-components/src/Chart/Donut.svelte b/packages/standard-components/src/Chart/Donut.svelte index ba650bdc5c..6ee6285417 100644 --- a/packages/standard-components/src/Chart/Donut.svelte +++ b/packages/standard-components/src/Chart/Donut.svelte @@ -1,36 +1,129 @@ - +
+{#if useLegend} +
+{/if} diff --git a/packages/standard-components/src/Chart/Line.svelte b/packages/standard-components/src/Chart/Line.svelte index 0d20360a95..5bbf40650f 100644 --- a/packages/standard-components/src/Chart/Line.svelte +++ b/packages/standard-components/src/Chart/Line.svelte @@ -1,17 +1,31 @@ - +
+{#if useLegend} +
+{/if}