49 lines
1.1 KiB
Vue
Raw Normal View History

2022-01-14 16:17:14 +08:00
<template>
<VChart :theme="themeColor" :option="option" autoresize></VChart>
2022-01-14 16:17:14 +08:00
</template>
<script setup lang="ts">
2022-02-02 18:17:45 +08:00
import { computed, PropType } from 'vue'
2022-01-25 22:29:44 +08:00
import VChart from 'vue-echarts'
2022-02-06 01:04:05 +08:00
import { use } from 'echarts/core'
2022-01-25 22:29:44 +08:00
import { CanvasRenderer } from 'echarts/renderers'
import { BarChart } from 'echarts/charts'
import config, { includes } from './config'
2022-03-20 16:13:33 +08:00
import { mergeTheme } from '@/packages/public/chart'
2022-01-26 17:38:16 +08:00
import {
DatasetComponent,
2022-01-26 17:38:16 +08:00
GridComponent,
TooltipComponent,
LegendComponent
2022-01-26 17:38:16 +08:00
} from 'echarts/components'
2022-01-25 22:29:44 +08:00
2022-01-24 21:12:18 +08:00
const props = defineProps({
2022-02-21 19:45:11 +08:00
themeSetting: {
type: Object,
required: true
},
themeColor: {
type: Object,
2022-02-06 01:04:05 +08:00
required: true
},
chartConfig: {
2022-01-25 22:29:44 +08:00
type: Object as PropType<config>,
required: true
}
})
use([
DatasetComponent,
2022-01-25 22:29:44 +08:00
CanvasRenderer,
BarChart,
GridComponent,
TooltipComponent,
LegendComponent
2022-01-25 22:29:44 +08:00
])
const option = computed(() => {
// TODO dataset的数据要设计一下不能这样把数据进行监听太耗性能
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
2022-01-25 22:29:44 +08:00
})
2022-01-14 16:17:14 +08:00
</script>