gpt4 book ai didi

javascript - HighCharts - 选择一个点时禁用鼠标悬停

转载 作者:行者123 更新时间:2023-12-02 21:42:49 24 4
gpt4 key购买 nike

我有以下两个图表:

enter image description here

折线图的配置如下:

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/

关于javascript - HighCharts - 选择一个点时禁用鼠标悬停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60327683/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com