Custom color bar chart
This commit is contained in:
parent
9ffca97ebc
commit
7c13d3ded9
|
@ -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",
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if options}
|
{#if options}
|
||||||
|
{#key options.customColor}
|
||||||
<div use:chart={options} use:styleable={$component.styles} />
|
<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 />
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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…
Reference in New Issue