From 46ae350370efbb436225d7e9d6a5ee5c00536dac Mon Sep 17 00:00:00 2001 From: Gerard Burns Date: Fri, 19 Apr 2024 09:25:59 +0100 Subject: [PATCH] think all charts and blocks are good --- .../components/app/blocks/ChartBlock.svelte | 4 ++-- .../app/charts/CandleStickChart.svelte | 3 +++ .../app/charts/HistogramChart.svelte | 20 +++++++++---------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/packages/client/src/components/app/blocks/ChartBlock.svelte b/packages/client/src/components/app/blocks/ChartBlock.svelte index 2767c44b8e..433d163909 100644 --- a/packages/client/src/components/app/blocks/ChartBlock.svelte +++ b/packages/client/src/components/app/blocks/ChartBlock.svelte @@ -32,7 +32,7 @@ // Bar/Line/Area export let valueColumns - export let yAxisUnits + export let valueUnits export let yAxisLabel export let xAxisLabel export let curve @@ -85,7 +85,7 @@ legend, animate, ...colors, - yAxisUnits, + valueUnits, yAxisLabel, xAxisLabel, stacked, diff --git a/packages/client/src/components/app/charts/CandleStickChart.svelte b/packages/client/src/components/app/charts/CandleStickChart.svelte index 0cee9e0e1e..11d491471f 100644 --- a/packages/client/src/components/app/charts/CandleStickChart.svelte +++ b/packages/client/src/components/app/charts/CandleStickChart.svelte @@ -55,6 +55,9 @@ } }, yaxis: { + labels: { + formatter: formatters[valueUnits] + }, title: { text: yAxisLabel } diff --git a/packages/client/src/components/app/charts/HistogramChart.svelte b/packages/client/src/components/app/charts/HistogramChart.svelte index 75e4456102..58a461d61e 100644 --- a/packages/client/src/components/app/charts/HistogramChart.svelte +++ b/packages/client/src/components/app/charts/HistogramChart.svelte @@ -13,7 +13,6 @@ export let width export let dataLabels export let animate - export let legend export let stacked export let palette export let c1, c2, c3, c4, c5 @@ -31,14 +30,6 @@ theme: { palette: palette === "Custom" ? null : palette }, - legend: { - show: legend, - position: "top", - horizontalAlign: "right", - showForSingleSeries: true, - showForNullSeries: true, - showForZeroSeries: true, - }, title: { text: title, }, @@ -141,8 +132,17 @@ } const getFormatter = (horizontal, axis) => { + // Don't display decimals in between integers on the value axis if ((horizontal && axis === "x") || (!horizontal && axis === "y")) { - return (value) => value.toFixed(0) + return (value) => { + if (Math.floor(value) === value) { + return value; + } + + // Returning an empty string or even a normal space here causes Apex Charts to push the value axis label of the screen + // This is an `em space`, `U+2003` + return " "; + } } return (value) => value