422
This commit is contained in:
@@ -4,14 +4,22 @@ import { guid } from '@/utils/util'
|
||||
|
||||
export function useEchart() {
|
||||
let chart = null
|
||||
let chartVal = ref(null)
|
||||
let id = ref(guid())
|
||||
const initChart = () => {
|
||||
const dom = document.getElementById(id.value)
|
||||
chart = echarts.init(dom)
|
||||
chartVal.value = chart
|
||||
}
|
||||
const setOption = (params, update = false) => {
|
||||
chart.setOption(params, update)
|
||||
}
|
||||
const clearOption = () => {
|
||||
// 将series设置为空数组,可以清空图表内容
|
||||
chart.setOption({
|
||||
series:[]
|
||||
})
|
||||
}
|
||||
const dispose = () => {
|
||||
chart.dispose()
|
||||
chart = null
|
||||
@@ -25,5 +33,5 @@ export function useEchart() {
|
||||
window.addEventListener('resize', resize)
|
||||
})
|
||||
|
||||
return { id, chart, setOption, dispose, initChart }
|
||||
return { id, chart, setOption, dispose, initChart,chartVal,clearOption }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user