Highcharts:悬停散点图系列时如何更改线条颜色

Highcharts: how to change line color when hovering a scatterplot series

我有一个 Highcharts 散点图。图表对象的一些细节如下:

plotOptions: {
scatter: {
    lineWidth:1,
    marker: {
        radius: 1,
        symbol:'circle',
        fillColor: '#800000',
        states: {
            hover: {
                enabled: true,
                radius:0,
                radiusPlus:2,
                lineColor: '#ff0000',
                fillColor: '#ff0000'
            }
        }
    },
    states: {
        hover: {
            halo:false,
            lineWidthPlus:2,
        }
    }
}
}

完整的工作示例是 here。 将系列悬停时,我需要更改线条颜色,但我做不到。这可能吗?

这可以通过事件轻松实现。

您只需在用户悬停在系列上时更新系列颜色属性

events: {
    mouseOver: function () {

        this.chart.series[this.index].update({
             color: 'red'
        });
    },
    mouseOut: function () {

        this.chart.series[this.index].update({
            color: "#b0b0b0"
        });                           
     }
 }

这将改变悬停点的系列的颜色。

here is update to your fiddle

希望对您有所帮助。

谢谢strikers

@HalvorStrand is sticky tracking disabled?? it is enabled by default. If you have multiple series and they run through same xAxis points, I advice to disable sticky tracking. – strikers Jan 4 at 5:23

我一直在努力解决这个问题,直到我把它放在 plotoptions 之后 series: {stickyTracking: false}, 问题已解决