Commit 8d356ea1 authored by liuzhaoh's avatar liuzhaoh

优化图表,进行联动

parent 4f1ef8fd
...@@ -178,7 +178,30 @@ const initChart = (instance, option, domEl) => { ...@@ -178,7 +178,30 @@ const initChart = (instance, option, domEl) => {
instance = echarts.init(document.getElementById(domEl)); instance = echarts.init(document.getElementById(domEl));
instance.setOption(option); instance.setOption(option);
chartInstance[domEl] = instance; chartInstance[domEl] = instance;
chartLinkageFun()
}; };
// 图表联动
const chartLinkageFun = (target) => {
Object.keys(chartInstance).forEach((currentKey) => {
chartInstance[currentKey].on('mousemove', (params) => {
Object.keys(chartInstance).forEach((key) => {
// if (key !== currentKey) {
chartInstance[key].dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: params.dataIndex
})
// }
})
})
})
}
// 移出图表事件
const chartRemoveEvent = () => {
Object.keys(chartInstance).forEach((key) => {
chartInstance[key].off()
})
}
const dustInfo = reactive([ const dustInfo = reactive([
{ {
label: "压差", label: "压差",
...@@ -573,6 +596,7 @@ onMounted(() => { ...@@ -573,6 +596,7 @@ onMounted(() => {
}); });
onUnmounted(() => { onUnmounted(() => {
window.removeEventListener("resize", resizeFun); window.removeEventListener("resize", resizeFun);
chartRemoveEvent()
}) })
watch( watch(
() => form.dusterNo, () => form.dusterNo,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment