当将一系列悬停在 HighCharts 散点图(此处为JSFiddle 演示)时,我采用了此解决方案来更改线条颜色:
$(function () {
$('#container').highcharts({
chart: {
type: 'scatter',
},
plotOptions: {
scatter: {
lineWidth:1,
marker: {
radius: 1,
symbol:'circle',
fillColor: '#800000',
states: {
hover: {
enabled: true,
radius:0,
radiusPlus:2,
lineColor: '#ff0000',
fillColor: '#ff0000'
}
}
},
events: {
mouseOver: function () {
this.chart.series[this.index].update({
color: 'red'
});
},
mouseOut: function () {
this.chart.series[this.index].update({
color: "#b0b0b0"
});
}
}
}
},
series: [{
name: 'A',
color: "#b0b0b0",
data: [[38,42],[39,39],[35,45],[35,54],{x:36,y:35,marker:{radius:8,symbol:'circle'}}
]
}, {
name: 'B',
color: "#b0b0b0",
data: [[46,56],[47,67],[48,69],[50,55],{x:52,y:57,marker:{radius:8,symbol:'circle'}}
]
}]
});
});
该脚本有效,但运行 Web 控制台时,我看到系列的每次悬停都会导致TypeError: g.firePointEvent is not a function error
.
在我的另一个脚本中,错误是TypeError: hoverPoint.firePointEvent is not a function
.
这是 HighCharts 的错误还是可以避免它?
该问题是由在您的操作之前调用的更新引起的。因此,您尝试在结束之前引用更新点。解决方案是使用 attr() 方法并更改路径上的 SVG 颜色。
events: {
mouseOver: function() {
this.chart.series[this.index].graph.attr({
stroke: 'red'
});
},
mouseOut: function() {
this.chart.series[this.index].graph.attr({
stroke: '#b0b0b0'
});
}
}
演示:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句