update dashboard

This commit is contained in:
2026-03-20 14:38:18 +08:00
parent c34f37e88f
commit d46140a3bd
4 changed files with 16 additions and 20 deletions
@@ -66,11 +66,16 @@ function handleDataTypeChange(val: unknown) {
emit('update:dataType', (val as string) || undefined)
}
watch(flatData, () => {
if (chart) {
chart.changeData(flatData.value)
watch(flatData, (newData) => {
if (newData.length === 0 && chart) {
chart.destroy()
chart = null
} else if (!chart && chartRef.value && newData.length > 0) {
nextTick(() => createChart())
} else if (chart) {
chart.changeData(newData)
}
})
}, { flush: 'post' })
onMounted(() => {
if (props.data.length > 0) {
@@ -78,15 +83,6 @@ onMounted(() => {
}
})
watch(
() => props.data,
(newVal) => {
if (newVal.length > 0 && !chart) {
nextTick(() => createChart())
}
},
)
onBeforeUnmount(() => {
if (chart) {
chart.destroy()