From b47589cdad16020ff30ef15d7691c356b63b8fc1 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 4 Nov 2020 13:08:59 +0000 Subject: [PATCH] Improve robustness of pie and donut charts --- .../src/Chart/BarChart.svelte | 6 +-- .../src/Chart/LineChart.svelte | 4 +- .../src/Chart/PieChart.svelte | 50 +++++++++++-------- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/packages/standard-components/src/Chart/BarChart.svelte b/packages/standard-components/src/Chart/BarChart.svelte index e8b6924db9..5e1e085310 100644 --- a/packages/standard-components/src/Chart/BarChart.svelte +++ b/packages/standard-components/src/Chart/BarChart.svelte @@ -5,6 +5,7 @@ import { ApexOptionsBuilder } from "./ApexOptionsBuilder" import ApexChart from "./ApexChart.svelte" + export let _bb export let title export let datasource export let labelColumn @@ -20,6 +21,7 @@ export let stacked export let yAxisUnits + const store = _bb.store let options // Fetch data on mount @@ -28,7 +30,7 @@ return } - const result = (await fetchData(datasource)).slice(0, 20) + const result = (await fetchData(datasource, $store)).slice(0, 20) const data = sortBy(row => row[labelColumn])(result) const schema = await fetchSchema(datasource.tableId) if (!schema || !data || !data.length) { @@ -86,8 +88,6 @@ // Build chart options options = builder.getOptions() }) - - $: console.log(options) diff --git a/packages/standard-components/src/Chart/LineChart.svelte b/packages/standard-components/src/Chart/LineChart.svelte index 38eb7623ac..577613ef4f 100644 --- a/packages/standard-components/src/Chart/LineChart.svelte +++ b/packages/standard-components/src/Chart/LineChart.svelte @@ -6,6 +6,7 @@ import ApexChart from "./ApexChart.svelte" // Common props + export let _bb export let title export let datasource export let labelColumn @@ -26,6 +27,7 @@ export let stacked export let gradient + const store = _bb.store let options // Fetch data on mount @@ -34,7 +36,7 @@ return } - const result = (await fetchData(datasource)).slice(0, 100) + const result = (await fetchData(datasource, $store)).slice(0, 100) const data = sortBy(row => row[labelColumn])(result) const schema = await fetchSchema(datasource.tableId) if (!schema || !data || !data.length) { diff --git a/packages/standard-components/src/Chart/PieChart.svelte b/packages/standard-components/src/Chart/PieChart.svelte index 4382cf220f..0a28907956 100644 --- a/packages/standard-components/src/Chart/PieChart.svelte +++ b/packages/standard-components/src/Chart/PieChart.svelte @@ -1,11 +1,11 @@