Javascript 图表初始化后,如何更改highcharts事件
图表初始化后,如何更改highcharts事件Javascript 图表初始化后,如何更改highcharts事件,javascript,highcharts,Javascript,Highcharts,图表初始化后,如何更改highcharts事件 <div id='report'></div> var chart = $('#container').highcharts({ chart: { }, xAxis: { }, plotOptions: { series: { point: {
<div id='report'></div>
var chart = $('#container').highcharts({
chart: {
},
xAxis: {
},
plotOptions: {
series: {
point: {
events: {
mouseOver: function() {
$reporting.html('inner x: '+ this.x +', y: '+ this.y);
}
}
},
events: {
mouseOut: function() {
$reporting.empty();
}
}
}
},
tooltip: {
enabled: false
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
chart.options.plotOptions.series.point.events.mouseOver = function() {
$('#report').html('outer x: ' + this.x + ', y: ' + this.y);
}
var图表=$(“#容器”)。highcharts({
图表:{
},
xAxis:{
},
打印选项:{
系列:{
要点:{
活动:{
mouseOver:function(){
$reporting.html('inner x:'+this.x+',y:'+this.y);
}
}
},
活动:{
mouseOut:function(){
$reporting.empty();
}
}
}
},
工具提示:{
已启用:false
},
系列:[{
数据:[29.9,71.5,106.4,129.2,144.0,176.0,135.6148.5,216.4194.1,95.6,54.4]
}]
});
chart.options.plotOptions.series.point.events.mouseOver=函数(){
$('#report').html('outer x:'+this.x+',y:'+this.y);
}
我想如上所述覆盖mouseOver事件,但它似乎没有生效。
我非常感谢任何人能提供帮助。不支持实时更新plotOptions 您可以通过以下方式更新一个系列选项:
chart.series[0].update({
point: {
events: {
mouseOver: function() {
$('#report').html('outer x: ' + this.x + ', y: ' + this.y);
}
}
}
});
嗨,PawełFus,非常感谢你的帮助。但是,除非做一些更改,否则它不会起作用<代码>chart.options.plotOptions.series.point.events.mouseOver=function(){$('#report').html('outer x:'+this.x+',y:'+this.y);};chart.series[0]。更新()代码>更新中我的坏的、错误的对象,现在正在工作。请参阅更新的答案。不过,您的解决方案也是正确的。正如我之前所说的,我的更新答案很好,只需在尝试编辑某人的答案之前进行测试。我试过你的例子,效果很好。感谢您的耐心帮助。顺便说一句,我不打算编辑您的答案,因为我找不到在评论中添加代码块的正确方法。对此表示抱歉。