代码之家  ›  专栏  ›  技术社区  ›  tic

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

  •  1
  • tic  · 技术社区  · 10 年前

    我有一张海图散点图。图表对象的一些详细信息如下:

    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 . 我需要在悬停系列时更改线条颜色,但我无法做到。这可能吗?

    2 回复  |  直到 10 年前
        1
  •  3
  •   Strikers    10 年前

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

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

    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

    希望这对你有所帮助。

        2
  •  1
  •   Carlos Maldonado    9 年前

    非常感谢。 strikers

    @HalvorStrand已禁用粘性跟踪??默认情况下启用。如果您有多个系列,并且它们通过相同的xAxis点运行,我建议禁用粘性跟踪。罢工者1月4日5:23

    我一直在纠结,直到我把它放在布景之后 series: {stickyTracking: false}, 问题已解决

    推荐文章