2022-09-15 01:28:57 +08:00
|
|
|
<template>
|
2022-09-15 18:41:17 +08:00
|
|
|
<v-chart ref="vChartRef" :theme="themeColor" :option="option" :manual-update="isPreview()" autoresize> </v-chart>
|
2022-09-15 01:28:57 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2022-09-15 18:41:17 +08:00
|
|
|
import { PropType, computed } from 'vue'
|
2022-09-15 01:28:57 +08:00
|
|
|
import VChart from 'vue-echarts'
|
|
|
|
|
import { use } from 'echarts/core'
|
|
|
|
|
import { CanvasRenderer } from 'echarts/renderers'
|
2022-09-15 18:41:17 +08:00
|
|
|
import { ScatterChart, EffectScatterChart } from 'echarts/charts'
|
2022-09-15 12:07:01 +08:00
|
|
|
import config, { includes } from './config'
|
2022-09-15 01:28:57 +08:00
|
|
|
import { mergeTheme } from '@/packages/public/chart'
|
|
|
|
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
|
|
|
|
import { useChartDataFetch } from '@/hooks'
|
|
|
|
|
import { isPreview } from '@/utils'
|
|
|
|
|
import { DatasetComponent, GridComponent, TooltipComponent, LegendComponent } from 'echarts/components'
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
themeSetting: {
|
|
|
|
|
type: Object,
|
|
|
|
|
required: true
|
|
|
|
|
},
|
|
|
|
|
themeColor: {
|
|
|
|
|
type: Object,
|
|
|
|
|
required: true
|
|
|
|
|
},
|
|
|
|
|
chartConfig: {
|
|
|
|
|
type: Object as PropType<config>,
|
|
|
|
|
required: true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
2022-09-15 18:41:17 +08:00
|
|
|
use([
|
|
|
|
|
DatasetComponent,
|
|
|
|
|
CanvasRenderer,
|
|
|
|
|
ScatterChart,
|
|
|
|
|
EffectScatterChart,
|
|
|
|
|
GridComponent,
|
|
|
|
|
TooltipComponent,
|
|
|
|
|
LegendComponent
|
|
|
|
|
])
|
2022-09-15 01:28:57 +08:00
|
|
|
|
|
|
|
|
const option = computed(() => {
|
|
|
|
|
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore)
|
|
|
|
|
</script>
|