52 lines
1.1 KiB
Vue
Raw Normal View History

2022-01-14 16:17:14 +08:00
<template>
<v-chart :theme="themeColor" :option="option" autoresize></v-chart>
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 { includes } from './config'
2022-03-20 16:13:33 +08:00
import { mergeTheme } from '@/packages/public/chart'
import { useChartDataFetch } from '@/hooks/useChartDataFetch.hook'
import { CreateComponentType } from '@/packages/index.d'
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: {
type: Object as PropType<CreateComponentType>,
2022-01-25 22:29:44 +08:00
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(() => {
return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
2022-01-25 22:29:44 +08:00
})
useChartDataFetch(props.chartConfig)
2022-01-14 16:17:14 +08:00
</script>