Separate chart loading state from error state

This commit is contained in:
Andrew Kingston 2020-11-04 15:43:43 +00:00
parent 9a4fc35bba
commit 8fde781a95
5 changed files with 9 additions and 1 deletions

View File

@ -6,7 +6,7 @@
{#if options}
<div use:chart={options} />
{:else}
{:else if options === false}
<div>Invalid chart options</div>
{/if}

View File

@ -26,6 +26,7 @@
// Fetch data on mount
onMount(async () => {
if (!datasource || !labelColumn || !valueColumns || !valueColumns.length) {
options = false
return
}
@ -39,6 +40,7 @@
.slice(0, 20)
.sort((a, b) => (a[labelColumn] > b[labelColumn] ? 1 : -1))
if (!schema || !data.length) {
options = false
return
}

View File

@ -26,6 +26,7 @@
onMount(async () => {
const allCols = [dateColumn, openColumn, highColumn, lowColumn, closeColumn]
if (!datasource || allCols.find(x => x == null)) {
options = false
return
}
@ -39,6 +40,7 @@
.slice(0, 100)
.sort((a, b) => (a[dateColumn] > b[dateColumn] ? 1 : -1))
if (!schema || !data.length) {
options = false
return
}

View File

@ -32,6 +32,7 @@
// Fetch data on mount
onMount(async () => {
if (!datasource || !labelColumn || !valueColumns || !valueColumns.length) {
options = false
return
}
@ -45,6 +46,7 @@
.slice(0, 100)
.sort((a, b) => (a[labelColumn] > b[labelColumn] ? 1 : -1))
if (!schema || !data.length) {
options = false
return
}

View File

@ -23,6 +23,7 @@
// Fetch data on mount
onMount(async () => {
if (!datasource || !labelColumn || !valueColumn) {
options = false
return
}
@ -34,6 +35,7 @@
.slice(0, 20)
.sort((a, b) => (a[labelColumn] > b[labelColumn] ? 1 : -1))
if (!schema || !data.length) {
options = false
return
}