2022-01-14 16:17:14 +08:00
|
|
|
|
<template>
|
2022-03-14 16:07:35 +08:00
|
|
|
|
<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'
|
2022-02-24 17:23:20 +08:00
|
|
|
|
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 {
|
2022-03-18 20:36:05 +08:00
|
|
|
|
DatasetComponent,
|
2022-01-26 17:38:16 +08:00
|
|
|
|
GridComponent,
|
|
|
|
|
TooltipComponent,
|
2022-02-24 17:23:20 +08:00
|
|
|
|
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
|
|
|
|
|
},
|
2022-02-24 17:23:20 +08:00
|
|
|
|
chartConfig: {
|
2022-01-25 22:29:44 +08:00
|
|
|
|
type: Object as PropType<config>,
|
|
|
|
|
required: true
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
use([
|
2022-03-18 20:36:05 +08:00
|
|
|
|
DatasetComponent,
|
2022-01-25 22:29:44 +08:00
|
|
|
|
CanvasRenderer,
|
|
|
|
|
BarChart,
|
|
|
|
|
GridComponent,
|
|
|
|
|
TooltipComponent,
|
2022-02-24 17:23:20 +08:00
|
|
|
|
LegendComponent
|
2022-01-25 22:29:44 +08:00
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
const option = computed(() => {
|
2022-03-19 23:28:33 +08:00
|
|
|
|
// 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>
|