2022-01-14 16:17:14 +08:00
|
|
|
<template>
|
2022-02-21 19:45:11 +08:00
|
|
|
<VChart :theme="themeColor" :option="option" autoresize />
|
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-21 19:45:11 +08:00
|
|
|
import config from './config'
|
|
|
|
import merge from 'lodash/merge'
|
2022-01-26 17:38:16 +08:00
|
|
|
import {
|
|
|
|
GridComponent,
|
|
|
|
TooltipComponent,
|
2022-02-21 19:45:11 +08:00
|
|
|
LegendComponent,
|
|
|
|
TitleComponent
|
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-01-25 22:29:44 +08:00
|
|
|
chartData: {
|
|
|
|
type: Object as PropType<config>,
|
|
|
|
required: true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
use([
|
|
|
|
CanvasRenderer,
|
|
|
|
BarChart,
|
|
|
|
GridComponent,
|
|
|
|
TooltipComponent,
|
2022-02-21 19:45:11 +08:00
|
|
|
LegendComponent,
|
|
|
|
TitleComponent
|
2022-01-25 22:29:44 +08:00
|
|
|
])
|
|
|
|
|
|
|
|
const option = computed(() => {
|
2022-02-21 19:45:11 +08:00
|
|
|
return merge(props.chartData.option, props.themeSetting)
|
2022-01-25 22:29:44 +08:00
|
|
|
})
|
2022-01-14 16:17:14 +08:00
|
|
|
</script>
|