index.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <v-chart ref="vChartRef" :theme="themeColor" :option="option" :manual-update="isPreview()" autoresize></v-chart>
  3. </template>
  4. <script setup lang="ts">
  5. import { computed, PropType } from 'vue'
  6. import VChart from 'vue-echarts'
  7. import { use } from 'echarts/core'
  8. import { CanvasRenderer } from 'echarts/renderers'
  9. import { PieChart } from 'echarts/charts'
  10. import { mergeTheme } from '@/packages/public/chart'
  11. import config, { includes } from './config'
  12. import { useChartDataFetch } from '@/hooks'
  13. import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
  14. import { isPreview } from '@/utils'
  15. import {
  16. DatasetComponent,
  17. GridComponent,
  18. TooltipComponent,
  19. LegendComponent,
  20. } from 'echarts/components'
  21. const props = defineProps({
  22. themeSetting: {
  23. type: Object,
  24. required: true
  25. },
  26. themeColor: {
  27. type: Object,
  28. required: true
  29. },
  30. chartConfig: {
  31. type: Object as PropType<config>,
  32. required: true
  33. }
  34. })
  35. use([
  36. DatasetComponent,
  37. CanvasRenderer,
  38. PieChart,
  39. GridComponent,
  40. TooltipComponent,
  41. LegendComponent,
  42. ])
  43. const option = computed(() => {
  44. return mergeTheme(props.chartConfig.option, props.themeSetting, includes)
  45. })
  46. const { vChartRef } = useChartDataFetch(props.chartConfig, useChartEditStore)
  47. </script>