highcharts = Highcharts;
chartOptions = {
chart: {
type: "line"
},
credits: {
enabled: false
},
title: {
enabled: true,
text: "Reach +1/" + this.xAxis.name,
verticalAlign: "top",
align: "left"
},
tooltip: {
formatter: function (data) {
return data.chart.userOptions.xAxis.title.text + ": " + this.x.toFixed(4) + "<br/>" +
"Reach: " + this.y.toFixed(4);
}
},
xAxis: {
title: {
text: this.xAxis.name
},
},
yAxis: {
title: {
text: "Reach"
}
},
series: [
{
name: this.xAxis.name,
data: null,
allowPointSelect: true,
point: {
events: {
click(event) {
const point = this;
console.log(point.selected);
const selected = (point.selected === true) ? false : true;
point.series.points.forEach(p => {
p.update({
marker: {
enabled: false
}
}, false);
});
if (selected === false) {
point.update({
marker: {
enabled: false
}
});
} else {
point.update({
marker: {
enabled: true
}
});
}
},
mouseOver: function(event) {
this.filterOptimizationResults(event.target.x, event.target.y);
}.bind(this)
}
}
}
]
};
将鼠标悬停在任何一点时,都会触发一个函数来更新右侧的饼图。
在折线图上,我也可以单击一个点以使其聚焦。
我要做的是,当我单击折线图上的任何点时,请禁用MouseOver功能,以便直到取消选择所选点之前饼图都不会更新。
有什么建议么?
最佳答案
您可以在mouseOver
函数中有条件地运行一些代码,例如:
series: [{
...,
point: {
events: {
mouseOver: function(){
if (!this.series.points.filter((p) => p.selected).length) {
// do something
}
}
}
}
}]
现场演示:http://jsfiddle.net/BlackLabel/6m4e8x0y/4886/