功能选择按钮修改
This commit is contained in:
@@ -31,7 +31,8 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
const customData: any = ref({}),
|
||||
legendData: any = ref({});
|
||||
legendData: any = ref({}),
|
||||
chart: any = ref();
|
||||
const init = () => {
|
||||
customData.value = {
|
||||
title: "", //标题
|
||||
@@ -50,7 +51,7 @@ const init = () => {
|
||||
itemGap: 0, // 设置图例项之间的间隔为20
|
||||
...props.legendData,
|
||||
};
|
||||
var chart = chartsRef.value && echarts.init(chartsRef.value);
|
||||
chart.value = chartsRef.value && echarts.init(chartsRef.value)
|
||||
var option = {
|
||||
title: {
|
||||
text: customData.value.title,
|
||||
@@ -90,26 +91,24 @@ const init = () => {
|
||||
},
|
||||
],
|
||||
};
|
||||
option && chart.setOption(option);
|
||||
option &&chart.value&& chart.value.setOption(option);
|
||||
setTimeout(() => {
|
||||
chart.resize();
|
||||
chart.value.resize();
|
||||
}, 0);
|
||||
};
|
||||
const resizeCharts = () => {
|
||||
var chart = chartsRef.value && echarts.init(chartsRef.value);
|
||||
if (chart) {
|
||||
chart.resize();
|
||||
if (chart.value) {
|
||||
chart.value.resize();
|
||||
}
|
||||
};
|
||||
window.addEventListener("resize", resizeCharts);
|
||||
onUnmounted(() => {
|
||||
var chart = chartsRef.value && echarts.init(chartsRef.value);
|
||||
if (chart) {
|
||||
chart.resize();
|
||||
if (chart.value) {
|
||||
chart.value.resize();
|
||||
}
|
||||
window.removeEventListener("resize", resizeCharts);
|
||||
if (chart) {
|
||||
chart.dispose();
|
||||
if (chart.value != null && chart.value.dispose) {
|
||||
chart.value.dispose(); // 销毁图表
|
||||
}
|
||||
});
|
||||
watch(
|
||||
|
||||
Reference in New Issue
Block a user