Browse Source

Custom color bar chart

master
Mel O'Hagan 4 years ago
parent
commit
38e8971019
  1. 13
      packages/client/manifest.json
  2. 4
      packages/client/src/components/app/charts/ApexChart.svelte
  3. 10
      packages/client/src/components/app/charts/ApexOptionsBuilder.js
  4. 12
      packages/client/src/components/app/charts/BarChart.svelte

13
packages/client/manifest.json

@ -1466,10 +1466,11 @@
}, },
{ {
"type": "select", "type": "select",
"label": "Colours", "label": "Colors",
"key": "palette", "key": "palette",
"defaultValue": "Palette 1", "defaultValue": "Palette 1",
"options": [ "options": [
"Custom",
"Palette 1", "Palette 1",
"Palette 2", "Palette 2",
"Palette 3", "Palette 3",
@ -1482,6 +1483,16 @@
"Palette 10" "Palette 10"
] ]
}, },
{
"type": "color",
"label": "C1",
"key": "c1",
"barSeparator": false,
"dependsOn": {
"setting": "palette",
"value": "Custom"
}
},
{ {
"type": "boolean", "type": "boolean",
"label": "Stacked", "label": "Stacked",

4
packages/client/src/components/app/charts/ApexChart.svelte

@ -10,7 +10,9 @@
</script> </script>
{#if options} {#if options}
<div use:chart={options} use:styleable={$component.styles} /> {#key options.customColor}
<div use:chart={options} use:styleable={$component.styles} />
{/key}
{:else if $builderStore.inBuilder} {:else if $builderStore.inBuilder}
<div use:styleable={$component.styles}> <div use:styleable={$component.styles}>
<Placeholder /> <Placeholder />

10
packages/client/src/components/app/charts/ApexOptionsBuilder.js

@ -62,8 +62,14 @@ export class ApexOptionsBuilder {
return this.setOption(["title", "text"], title) return this.setOption(["title", "text"], title)
} }
color(color) { colors(colors) {
return this.setOption(["colors"], [color]) if (!colors) {
delete this.options.colors
this.options["customColor"] = false
return this
}
this.options["customColor"] = true
return this.setOption(["colors"], colors)
} }
width(width) { width(width) {

12
packages/client/src/components/app/charts/BarChart.svelte

@ -16,6 +16,7 @@
export let stacked export let stacked
export let yAxisUnits export let yAxisUnits
export let palette export let palette
export let c1, c2, c3, c4, c5
export let horizontal export let horizontal
$: options = setUpChart( $: options = setUpChart(
@ -33,9 +34,13 @@
stacked, stacked,
yAxisUnits, yAxisUnits,
palette, palette,
horizontal horizontal,
c1 ? [c1] : null,
customColor
) )
$: customColor = palette === "Custom"
const setUpChart = ( const setUpChart = (
title, title,
dataProvider, dataProvider,
@ -51,7 +56,9 @@
stacked, stacked,
yAxisUnits, yAxisUnits,
palette, palette,
horizontal horizontal,
colors,
customColor
) => { ) => {
const allCols = [labelColumn, ...(valueColumns || [null])] const allCols = [labelColumn, ...(valueColumns || [null])]
if ( if (
@ -85,6 +92,7 @@
.stacked(stacked) .stacked(stacked)
.palette(palette) .palette(palette)
.horizontal(horizontal) .horizontal(horizontal)
.colors(customColor ? colors : null)
// Add data // Add data
let useDates = false let useDates = false

Loading…
Cancel
Save