feat: supply option panel of gloabl and bar chart setting

This commit is contained in:
skie1997
2024-12-20 15:44:24 +08:00
parent 026e4809c8
commit 152786c652
20 changed files with 8049 additions and 32 deletions
+7 -4
View File
@@ -10,6 +10,8 @@
<script setup lang="ts">
import { ref, PropType, watch, onMounted, onBeforeUnmount, nextTick } from 'vue'
import { VChart, type IVChart, type IInitOption, type ISpec } from '@visactor/vchart'
import { transformHandler } from './transformProps'
import { IOption } from '@/packages/components/VChart/index.d'
// 事件说明 v1.13.0 https://www.visactor.io/vchart/api/API/event
const event = [
@@ -189,13 +191,14 @@ watch(
// 更新
const createOrUpdateChart = (
chartProps: ISpec & {
chartProps: IOption & {
dataset: any
}
) => {
if (vChartRef.value && !chart) {
const spec = transformHandler[chartProps.category](chartProps)
chart = new VChart(
{ ...chartProps, data: chartProps.dataset },
{ ...spec, data: chartProps.dataset },
{
dom: vChartRef.value,
...props.initOptions
@@ -204,8 +207,8 @@ const createOrUpdateChart = (
chart.renderSync()
return true
} else if (chart) {
chart.updateSpec(chartProps)
chart.renderSync()
const spec = transformHandler[chartProps.category](chartProps)
chart.updateSpec({ ...spec, data: chartProps.dataset })
return true
}
return false