JinZHouXiYiJi_DaPin2/resource/echarts/ComChart/ComChart.vue

30 lines
633 B
Vue
Raw Permalink Normal View History

2023-12-05 13:23:01 +08:00
<template>
<div ref="chartEl" v-resize="resizeHandler"></div>
</template>
<script lang="ts" setup>
import { useData } from 'open-data-v/base'
import { ref } from 'vue'
import { useEchart } from '../hooks'
import type ComChartComponent from './config'
const props = defineProps<{
component: ComChartComponent
}>()
const chartEl = ref<ElRef>(null)
const { updateEchart, resizeHandler } = useEchart(chartEl)
const dataChange = (resp: any, _?: string) => {
if (!resp || !resp.afterData) {
return
}
if (resp.status === 'SUCCESS') {
updateEchart(resp.afterData)
}
}
useData(props.component, dataChange)
</script>