| | |
| | | resizeChart?.(width, height); |
| | | }; |
| | | |
| | | const initChart = ()=>{ |
| | | const initChart = () => { |
| | | setTimeout(() => { |
| | | const parent = chartRef.value.parentElement; |
| | | const parentBound = parent.getBoundingClientRect(); |
| | | chartInstance.value = echarts.init(chartRef.value, undefined, { |
| | | width: parentBound.width, |
| | | height: parentBound.height, |
| | | locale: 'ZH', |
| | | }); |
| | | resizeChart = debounce((width, height) => { |
| | | chartInstance.value.resize({ |
| | | width: width, |
| | | height: height, |
| | | const instance = echarts.getInstanceByDom(chartRef.value); |
| | | if (!instance) { |
| | | const parent = chartRef.value.parentElement; |
| | | const parentBound = parent.getBoundingClientRect(); |
| | | |
| | | chartInstance.value = echarts.init(chartRef.value, undefined, { |
| | | width: parentBound.width, |
| | | height: parentBound.height, |
| | | locale: 'ZH', |
| | | }); |
| | | }); |
| | | |
| | | resizeChart = debounce((width, height) => { |
| | | chartInstance.value.resize({ |
| | | width: width, |
| | | height: height, |
| | | }); |
| | | }); |
| | | } |
| | | |
| | | drawChart(); |
| | | }, 100); |
| | | } |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | initChart(); |
| | |
| | | return { |
| | | chartContainerResize, |
| | | chartInstance, |
| | | |
| | | }; |
| | | }; |