feat:对接接口、完善功能

This commit is contained in:
zjc
2024-12-26 18:30:52 +08:00
parent 809c950301
commit dc1ad009c7
16 changed files with 1085 additions and 1246 deletions

View File

@@ -3,26 +3,27 @@ import * as echarts from 'echarts'
import { guid } from '@/utils/util'
export function useEchart() {
let chart = ref(null)
let chart = null
let id = ref(guid())
const initChart = () => {
const dom = document.getElementById(id.value)
chart.value = echarts.init(dom)
chart = echarts.init(dom)
}
const setOption = (params) => {
chart.value.setOption(params)
chart.setOption(params)
}
const dispose = () => {
chart.dispose()
chart = null
}
const resize = () => {
if (chart) {
chart.dispose()
chart = null
initChart()
}
chart.resize()
}
onMounted(() => {
initChart()
// 监听窗口大小变化
window.addEventListener('resize', resize)
})
return { id, chart, setOption, initChart }
return { id, chart, setOption, dispose, initChart }
}