diff --git a/packages/builder/src/components/common/NavItem.svelte b/packages/builder/src/components/common/NavItem.svelte index 7aa535f289..5b1ede4394 100644 --- a/packages/builder/src/components/common/NavItem.svelte +++ b/packages/builder/src/components/common/NavItem.svelte @@ -14,7 +14,7 @@ class="nav-item" class:border class:selected - style={`padding-left: ${indentLevel * 18}px`} + style={`padding-left: ${indentLevel * 14}px`} {draggable} on:dragend on:dragstart @@ -65,7 +65,7 @@ } .content { - padding: 0 var(--spacing-m); + padding: 0 var(--spacing-s); height: 32px; display: flex; flex-direction: row; @@ -97,6 +97,9 @@ flex: 1 1 auto; font-weight: 500; font-size: var(--font-size-xs); + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; } .actions { diff --git a/packages/builder/src/components/userInterface/ComponentsHierarchyChildren.svelte b/packages/builder/src/components/userInterface/ComponentsHierarchyChildren.svelte index 7bedf5e6a8..1034238c0a 100644 --- a/packages/builder/src/components/userInterface/ComponentsHierarchyChildren.svelte +++ b/packages/builder/src/components/userInterface/ComponentsHierarchyChildren.svelte @@ -129,7 +129,7 @@ ondragover="return false" ondragenter="return false" class="drop-item" - style="margin-left: {(level + 1) * 18}px" /> + style="margin-left: {(level + 1) * 16}px" /> {/if} + style="margin-left: {(level + ($dragDropStore.dropPosition === 'inside' ? 3 : 1)) * 16}px" /> {/if} {/each} @@ -176,6 +176,6 @@ .drop-item { border-radius: var(--border-radius-m); height: 32px; - background: var(--blue-light); + background: var(--grey-3); } diff --git a/packages/builder/src/components/userInterface/MultiOptionSelect.svelte b/packages/builder/src/components/userInterface/MultiOptionSelect.svelte new file mode 100644 index 0000000000..5122969975 --- /dev/null +++ b/packages/builder/src/components/userInterface/MultiOptionSelect.svelte @@ -0,0 +1,42 @@ + + +
+ + {#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/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 @@ - +{#if multiselect} + +{:else} + +{/if} diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 1c4bc632a6..ef88c93001 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -1,5 +1,6 @@ import Input from "./PropertyPanelControls/Input.svelte" import OptionSelect from "./OptionSelect.svelte" +import MultiTableViewFieldSelect from "./MultiTableViewFieldSelect.svelte" import Checkbox from "../common/Checkbox.svelte" import TableSelect from "components/userInterface/TableSelect.svelte" import TableViewSelect from "components/userInterface/TableViewSelect.svelte" @@ -423,122 +424,40 @@ export default { 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: [ + { + label: "Title", + key: "title", + control: Input, + }, { label: "Data", key: "datasource", control: TableViewSelect, }, { - label: "Name Label", - key: "nameLabel", + label: "Label Col.", + key: "labelColumn", dependsOn: "datasource", control: TableViewFieldSelect, }, { - label: "Value Label", - key: "valueLabel", + label: "Data Cols.", + key: "valueColumns", dependsOn: "datasource", - control: TableViewFieldSelect, + control: MultiTableViewFieldSelect, + }, + { + label: "Format", + key: "yAxisUnits", + control: OptionSelect, + options: ["Default", "Thousands", "Millions"], + defaultValue: "Default", }, { label: "Y Axis Label", @@ -550,56 +469,6 @@ 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", @@ -609,221 +478,92 @@ export default { label: "Height", key: "height", 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", + control: Checkbox, + valueKey: "checked", + defaultValue: false, + }, + { + label: "Data Labels", + key: "dataLabels", + control: Checkbox, + valueKey: "checked", + defaultValue: false, }, { label: "Animate", - key: "isAnimate", + key: "animate", control: Checkbox, valueKey: "checked", + defaultValue: true, }, { - label: "Horizontal", - key: "isHorizontal", + label: "Legend", + key: "legend", control: Checkbox, valueKey: "checked", - }, - { - label: "Label Number Format", - key: "labelsNumberFormat", - control: Input, + defaultValue: false, }, ], }, }, { - 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", properties: { settings: [ + { + label: "Title", + key: "title", + control: Input, + }, { label: "Data", key: "datasource", control: TableViewSelect, }, { - label: "Value Label", - key: "valueLabel", + label: "Label Col.", + key: "labelColumn", dependsOn: "datasource", control: TableViewFieldSelect, }, { - label: "Topic Label", - key: "topicLabel", + label: "Data Cols.", + key: "valueColumns", dependsOn: "datasource", - control: TableViewFieldSelect, + control: MultiTableViewFieldSelect, }, { - label: "Date Label", - key: "dateLabel", - dependsOn: "datasource", - control: TableViewFieldSelect, - }, - { - label: "Colors", - key: "color", + label: "Format", + key: "yAxisUnits", 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, + options: ["Default", "Thousands", "Millions"], + defaultValue: "Default", }, { label: "Y Axis Label", @@ -831,10 +571,9 @@ export default { control: Input, }, { - label: "Show All Datapoints", - key: "shouldShowAllDataPoints", - valueKey: "checked", - control: Checkbox, + label: "X Axis Label", + key: "xAxisLabel", + control: Input, }, { label: "Width", @@ -845,57 +584,423 @@ export default { label: "Height", key: "height", control: Input, + defaultValue: "400", }, { - label: "Is Animated", - key: "isAnimated", - control: Checkbox, - valueKey: "checked", - }, - { - label: "Locale", - key: "locale", + label: "Curve", + key: "curve", control: OptionSelect, - options: ["en-GB", "en-US"], + options: ["Smooth", "Straight", "Stepline"], + defaultValue: "Smooth", }, { - label: "X Axis Value Type", - key: "xAxisValueType", - control: OptionSelect, - options: ["date", "numeric"], - }, - { - label: "X Axis Format", - key: "xAxisFormat", + label: "Colours", + key: "palette", control: OptionSelect, + defaultValue: "Palette 1", options: [ - "day-month", - "minute-hour", - "hour-daymonth", - "month-year", - "custom", + "Palette 1", + "Palette 2", + "Palette 3", + "Palette 4", + "Palette 5", + "Palette 6", + "Palette 7", + "Palette 8", + "Palette 9", + "Palette 10", ], }, { - label: "X Axis Custom Format", - key: "xAxisCustomFormat", + 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: false, + }, + ], + }, + }, + { + 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: "Tooltip Title", - key: "tooltipTitle", + 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 Ticks", - key: "xTicks", + label: "X Label", + key: "xAxisLabel", control: Input, }, { - label: "Y Ticks", - key: "yTicks", + 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: "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", + 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: false, + }, + { + label: "Stacked", + key: "stacked", + control: Checkbox, + valueKey: "checked", + defaultValue: true, + }, + { + label: "Gradient", + key: "gradient", + control: Checkbox, + valueKey: "checked", + defaultValue: false, + }, + ], + }, + }, + { + 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: "Width", + key: "width", + control: Input, + }, + { + label: "Height", + key: "height", + 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", + 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: "Width", + key: "width", + control: Input, + }, + { + label: "Height", + key: "height", + 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", + 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: "Candlestick Chart", + _component: "@budibase/standard-components/candlestick", + description: "Candlestick chart", + icon: "ri-stock-line", + properties: { + settings: [ + { + label: "Title", + key: "title", + control: Input, + }, + { + label: "Data", + key: "datasource", + control: TableViewSelect, + }, + { + label: "Date Col.", + key: "dateColumn", + dependsOn: "datasource", + control: TableViewFieldSelect, + }, + { + label: "Open Col.", + key: "openColumn", + dependsOn: "datasource", + control: TableViewFieldSelect, + }, + { + label: "Close Col.", + key: "closeColumn", + dependsOn: "datasource", + control: TableViewFieldSelect, + }, + { + label: "High Col.", + key: "highColumn", + dependsOn: "datasource", + control: TableViewFieldSelect, + }, + { + label: "Low Col.", + key: "lowColumn", + dependsOn: "datasource", + control: TableViewFieldSelect, + }, + { + label: "Format", + key: "yAxisUnits", + control: OptionSelect, + options: ["Default", "Thousands", "Millions"], + defaultValue: "Default", + }, + { + label: "Y Axis Label", + key: "yAxisLabel", + control: Input, + }, + { + label: "X Axis Label", + key: "xAxisLabel", + control: Input, + }, + { + label: "Width", + key: "width", + control: Input, + }, + { + label: "Height", + key: "height", + control: Input, + defaultValue: "400", + }, + { + label: "Animate", + key: "animate", + control: Checkbox, + valueKey: "checked", + defaultValue: true, + }, ], }, }, 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 { 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; } diff --git a/packages/client/src/api/index.js b/packages/client/src/api/index.js index 36eb0f4d33..158ad8e800 100644 --- a/packages/client/src/api/index.js +++ b/packages/client/src/api/index.js @@ -80,27 +80,30 @@ const makeRowRequestBody = (parameters, state) => { if (body._table) delete body._table // then override with supplied parameters - for (let fieldName of Object.keys(parameters.fields)) { - const field = parameters.fields[fieldName] + if (parameters.fields) { + for (let fieldName of Object.keys(parameters.fields)) { + const field = parameters.fields[fieldName] - // ensure fields sent are of the correct type - if (field.type === "boolean") { - if (field.value === "true") body[fieldName] = true - if (field.value === "false") body[fieldName] = false - } else if (field.type === "number") { - const val = parseFloat(field.value) - if (!isNaN(val)) { - body[fieldName] = val + // ensure fields sent are of the correct type + if (field.type === "boolean") { + if (field.value === "true") body[fieldName] = true + if (field.value === "false") body[fieldName] = false + } else if (field.type === "number") { + const val = parseFloat(field.value) + if (!isNaN(val)) { + body[fieldName] = val + } + } else if (field.type === "datetime") { + const date = new Date(field.value) + if (!isNaN(date.getTime())) { + body[fieldName] = date.toISOString() + } + } else { + body[fieldName] = field.value } - } else if (field.type === "datetime") { - const date = new Date(field.value) - if (!isNaN(date.getTime())) { - body[fieldName] = date.toISOString() - } - } else { - body[fieldName] = field.value } } + return body } diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index 9adb3c02cf..5b258c3c17 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -396,286 +396,283 @@ } } }, - "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, "props": { + "title": "string", "datasource": "tables", - "nameLabel": "string", - "valueLabel": "string", - "betweenBarsPadding": "number", - "gradient": "string", - "color": "string", - "hasSingleBarHighlight": "bool", - "height": "number", - "width": "number", - "isAnimated": "bool", - "isHorizontal": "bool", - "labelNumberFormat": "number", - "locale": "string", + "labelColumn": "string", + "valueColumns": "string", + "height": { + "type": "string", + "default": "400" + }, + "width": "string", + "dataLabels": "bool", + "animate": { + "type": "bool", + "default": true + }, "xAxisLabel": "string", "yAxisLabel": "string", - "useLegend": "bool", - "xTicks": "number", - "yTicks": "number" + "legend": "bool", + "stacked": "bool", + "yAxisUnits": { + "type": "options", + "default": "Default", + "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" + ] + } } }, "line": { "description": "Line Chart", "data": true, "props": { + "title": "string", "datasource": "tables", - "width": "number", - "height": "number", - "axisTimeCombinations": "string", - "color": "string", - "grid": { + "labelColumn": "string", + "valueColumns": "string", + "height": { "type": "string", - "default": "horizontal" + "default": "400" }, - "aspectRatio": "number", - "dateLabel": "string", - "isAnimated": { + "width": "string", + "dataLabels": { + "type": "bool", + "default": false + }, + "animate": { "type": "bool", "default": true }, - "lineCurve": "string", - "locale": "string", - "numberFormat": "string", - "shouldShowAllDataPoints": { - "type": "bool", - "default": true - }, - "topicLabel": "string", - "valueLabel": "string", - "xAxisValueType": { - "type": "string", - "default": "date" - }, - "xAxisScale": "string", - "xAxisFormat": { - "type": "string", - "default": "custom" - }, - "xAxisCustomFormat": "string", "xAxisLabel": "string", "yAxisLabel": "string", - "tooltipTitle": "string", - "xTicks": "number", - "yTicks": "number" + "curve": { + "type": "options", + "options": [ + "Smooth", + "Straight", + "Stepline" + ], + "default": "Smooth" + }, + "legend": "bool", + "yAxisUnits": { + "type": "options", + "default": "Default", + "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" + ] + } } }, - "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", + "area": { + "description": "Area Chart", "data": true, "props": { + "title": "string", "datasource": "tables", - "nameLabel": "string", - "valueLabel": "string", - "color": "string", - "height": "string", + "labelColumn": "string", + "valueColumns": "string", + "height": { + "type": "string", + "default": "400" + }, "width": "string", - "margin": "string", - "grid": "string", - "groupLabel": "string", - "isAnimated": "bool", - "isHorizontal": "bool", - "yTicks": "string", - "useLegend": "bool", - "tooltipTitle": "string" + "dataLabels": { + "type": "bool", + "default": false + }, + "animate": { + "type": "bool", + "default": true + }, + "xAxisLabel": "string", + "yAxisLabel": "string", + "curve": { + "type": "options", + "options": [ + "Smooth", + "Straight", + "Stepline" + ], + "default": "Smooth" + }, + "legend": "bool", + "stacked": { + "type": "bool", + "default": true + }, + "gradient": "bool", + "yAxisUnits": { + "type": "options", + "default": "Default", + "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" + ] + } } }, - "bullet": { - "description": "Bullet chart", + "pie": { + "description": "Pie Chart", "data": true, "props": { - "table": "string", - "color": "string", - "customSubtitle": "string", - "customTitle": "string", - "numberFormat": "string", - "paddingBetweenAxisAndChart": "number", - "height": "number", - "width": "number" + "title": "string", + "datasource": "tables", + "labelColumn": "string", + "valueColumn": "string", + "height": { + "type": "string", + "default": "200" + }, + "width": "string", + "dataLabels": "bool", + "animate": { + "type": "bool", + "default": true + }, + "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" + ] + } + } + }, + "donut": { + "description": "Donut Chart", + "data": true, + "props": { + "title": "string", + "datasource": "tables", + "labelColumn": "string", + "valueColumn": "string", + "height": { + "type": "string", + "default": "200" + }, + "width": "string", + "dataLabels": "bool", + "animate": { + "type": "bool", + "default": true + }, + "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" + ] + } + } + }, + "candlestick": { + "description": "Candlestick Chart", + "data": true, + "props": { + "title": "string", + "datasource": "tables", + "dateColumn": "string", + "openColumn": "string", + "closeColumn": "string", + "highColumn": "string", + "lowColumn": "string", + "height": { + "type": "string", + "default": "400" + }, + "width": "string", + "animate": { + "type": "bool", + "default": true + }, + "xAxisLabel": "string", + "yAxisLabel": "string", + "yAxisUnits": { + "type": "options", + "default": "Default", + "options": [ + "Default", "Thousands", "Millions" + ] + } } }, "datepicker": { @@ -686,30 +683,6 @@ "placeholder": "string" } }, - "datachart": { - "description": "shiny chart", - "data": true, - "props": { - "table": "tables", - "type": { - "type": "options", - "default": "column2d", - "options": [ - "column3d", - "line", - "area2d", - "bar2d", - "bar3d", - "pie2d", - "pie3d", - "doughnut2d", - "doughnut3d", - "pareto2d", - "pareto3d" - ] - } - } - }, "link": { "name": "Link", "description": "an HTML anchor tag", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 7064396d10..1bd0303e30 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/ApexChart.svelte b/packages/standard-components/src/Chart/ApexChart.svelte new file mode 100644 index 0000000000..5bf319e7ea --- /dev/null +++ b/packages/standard-components/src/Chart/ApexChart.svelte @@ -0,0 +1,18 @@ + + +{#if options} +
+{:else if options === false} +
Invalid chart options
+{/if} + + diff --git a/packages/standard-components/src/Chart/ApexOptionsBuilder.js b/packages/standard-components/src/Chart/ApexOptionsBuilder.js new file mode 100644 index 0000000000..5c2ae1eb05 --- /dev/null +++ b/packages/standard-components/src/Chart/ApexOptionsBuilder.js @@ -0,0 +1,154 @@ +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: { + show: false, + position: "top", + horizontalAlign: "right", + showForSingleSeries: true, + showForNullSeries: true, + showForZeroSeries: true, + }, + chart: { + toolbar: { + show: false, + }, + zoom: { + enabled: false, + }, + }, + yaxis: { + labels: { + formatter: this.formatters.Default, + }, + }, + } + + 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) + } + + title(title) { + return this.setOption(["title", "text"], title) + } + + 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) + } + + curve(curve) { + return this.setOption(["stroke", "curve"], curve) + } + + gradient(gradient) { + const fill = { + type: "gradient", + gradient: { + shadeIntensity: 1, + opacityFrom: 0.7, + opacityTo: 0.9, + stops: [0, 90, 100], + }, + } + return this.setOption(["fill"], gradient ? fill : undefined) + } + + legend(legend) { + 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) + } + + yUnits(units) { + return this.setOption( + ["yaxis", "labels", "formatter"], + this.formatters[units || "Default"] + ) + } + + xType(type) { + return this.setOption(["xaxis", "type"], type) + } + + 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/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/Bar.svelte b/packages/standard-components/src/Chart/Bar.svelte deleted file mode 100644 index 24da930e14..0000000000 --- a/packages/standard-components/src/Chart/Bar.svelte +++ /dev/null @@ -1,187 +0,0 @@ - - -
diff --git a/packages/standard-components/src/Chart/BarChart.svelte b/packages/standard-components/src/Chart/BarChart.svelte new file mode 100644 index 0000000000..9fdc649dfa --- /dev/null +++ b/packages/standard-components/src/Chart/BarChart.svelte @@ -0,0 +1,99 @@ + + + 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/CandleStickChart.svelte b/packages/standard-components/src/Chart/CandleStickChart.svelte new file mode 100644 index 0000000000..c034855e5e --- /dev/null +++ b/packages/standard-components/src/Chart/CandleStickChart.svelte @@ -0,0 +1,74 @@ + + + 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/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/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/LineChart.svelte b/packages/standard-components/src/Chart/LineChart.svelte new file mode 100644 index 0000000000..866a672491 --- /dev/null +++ b/packages/standard-components/src/Chart/LineChart.svelte @@ -0,0 +1,100 @@ + + + diff --git a/packages/standard-components/src/Chart/PieChart.svelte b/packages/standard-components/src/Chart/PieChart.svelte new file mode 100644 index 0000000000..75cf1d5c6a --- /dev/null +++ b/packages/standard-components/src/Chart/PieChart.svelte @@ -0,0 +1,66 @@ + + + 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..008aa6b64f 100644 --- a/packages/standard-components/src/Chart/index.js +++ b/packages/standard-components/src/Chart/index.js @@ -1,14 +1,6 @@ -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" +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" +export { default as candlestick } from "./CandleStickChart.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/fetchData.js b/packages/standard-components/src/fetchData.js index 59b417a5c8..ef1950c5f7 100644 --- a/packages/standard-components/src/fetchData.js +++ b/packages/standard-components/src/fetchData.js @@ -14,12 +14,12 @@ export default async function fetchData(datasource, store) { } // Fetch table schema so we can check for linked rows - if (rows && rows.length) { - const table = await fetchTable() - const keys = Object.keys(table.schema) + if (rows && rows.length && datasource.tableId) { + const schema = await fetchSchema(datasource.tableId) + const keys = Object.keys(schema) rows.forEach(row => { for (let key of keys) { - const type = table.schema[key].type + const type = schema[key].type if (type === "link") { row[`${key}_count`] = Array.isArray(row[key]) ? row[key].length : 0 } else if (type === "attachment") { @@ -38,12 +38,6 @@ export default async function fetchData(datasource, store) { return [] } - async function fetchTable() { - const FETCH_TABLE_URL = `/api/tables/${datasource.tableId}` - const response = await api.get(FETCH_TABLE_URL) - return await response.json() - } - async function fetchTableData() { if (!name.startsWith("all_")) { throw new Error("Incorrect table convention - must begin with all_") @@ -85,3 +79,9 @@ export default async function fetchData(datasource, store) { return row[datasource.fieldName] } } + +export async function fetchSchema(id) { + const FETCH_TABLE_URL = `/api/tables/${id}` + const response = await api.get(FETCH_TABLE_URL) + return (await response.json()).schema +} 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"