4.0.0 dom多次执行setoption tooltip无法清除
One-line summary [问题简述]
我们用下拉框切换所需数据,当多次切换数据后 之前hover在图表上的tooltip一直显示在图表上无法清除,在数据切换时均执行了 clear dispose方法销毁实例。
Version & Environment [版本及环境]
- ECharts version [ECharts 版本]4.0.0
- Browser version [浏览器类型和版本]: chrome 63.0.3239
- OS Version [操作系统类型和版本]: win10
Expected behaviour [期望结果]
ECharts option [ECharts配置项]
option = {
}
Other comments [其他信息]
相同的问题,仅修改data部分,x轴、y轴上的label不会刷新,会不断叠加。
你们尝试过 action.tooltip.hideTip () 方法么? 我目前解决方案是把echarts盒子的dom清理掉再重新加div
@tangbohao37 不太知道怎么复现这个问题。 能不能给一下 option?以及不清楚几个问题: (1)tooltip 的触发,是通过鼠标 hover 触发的,还是通过调用 charts.dispatchAction({type: 'showTip', ...}) 触发的?如果是通过鼠标 hover 触发的,也就是说,”使用下拉框切换数据“ 的时候,tooltip 仍然是显示的状态? (2)切换数据后 setOption 之前是不是已经调用了:
chart.dispose();
然后
chart.setOption(...);
@100pah
option = {
legend: {
data: ['诊断人次', '确诊人次', '确诊率'],
textStyle: {
color: '#fff'
}
},
tooltip: {
trigger: 'axis',
},
grid: {
left: '6%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: [{
type: 'category',
data: PPSDateStart,
axisPointer: {
type: 'shadow'
},
axisLabel: {
show: true,
textStyle: {
color: '#aaa'
}
},
}],
yAxis: [{
type: 'value',
name: '人次',
min: 0,
max: 300000,
interval: 60000,
axisLabel: {
show: true,
textStyle: {
color: '#aaa'
}
},
splitLine: {
lineStyle: {
color: '#2F4A4A'
}
},
nameTextStyle: {
color: '#666'
}
},
{
type: 'value',
name: '确诊率',
min: 0,
max: 50,
interval: 10,
axisLabel: {
show: true,
textStyle: {
color: '#aaa'
}
},
splitLine: {
lineStyle: {
color: '#2F4A4A'
}
},
nameTextStyle: {
color: '#666'
}
}
],
series: [{
name: '诊断人次',
type: 'line',
smooth: 0.3,
data: patient_sum,
yAxisIndex: 0,
itemStyle: {
normal: {
color: '#2d9164',
formatter: '{value} %'
}
},
lineStyle: {
normal: {
color: '#2d9164'
}
},
},
{
name: '确诊率',
type: 'line',
smooth: 0.3,
yAxisIndex: 1,
lineStyle: {
normal: {
color: '#b7506c'
}
},
itemStyle: {
normal: {
color: '#b7506c'
}
},
data: jb_probability
},
{
name: '确诊人次',
type: 'line',
smooth: 0.3,
yAxisIndex: 0,
lineStyle: {
normal: {
color: '#4297ac'
}
},
itemStyle: {
normal: {
color: '#4297ac'
}
},
data: jb_sum
}
]
};
鼠标是通过hover触发的,是echarts默认配置,没有鼠标事件的额外代码。 下拉框选择后是先dispose,最后setoption,下拉框前几次选择都是没有问题的,tooltip正常关闭。 到达5/6次之后,页面就会出现前一次的tooltip,再选下拉框就会一直叠加。 这个问题我们之前试过3.8.5,和3.8.4 都不能解决,最后3.4.0版本似乎没有这个问题
到达 5/6 次之后会出问题,这个还挺奇怪的。 你们的页面有定时的 “数据加载 + setOption 刷新图表” 吗? 另外,选择下拉框的时候,tooltip 是显示的状态还是隐藏的状态?
@100pah 没有定时刷新。 在出问题后选择下拉框的时候tooltip还是显示状态。
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.