highcharts 有没有办法改变在hightcharts中悬停时图线的虚线样式?

mjqavswn  于 2023-08-05  发布在  Highcharts
关注(0)|答案(1)|浏览(167)

当用户将鼠标悬停在绘图线上时,我想更改其dashStyle
JSfiddle - https://jsfiddle.net/sharadkalya/5z1w06pL/17/
我尝试的方法如下:

plotOptions: {
    series: {
        states: {
            hover: {
                enabled: true,
                lineWidth: 5,
                line: {
                    dashStyle: "dash"
                },
                dashStyle: "dash",
            }
        }
    },
},

字符串
这样lineWidth会发生变化,但dashStyle不会发生变化。

uttx8gqw

uttx8gqw1#

plotOptions.series.states.hover中没有linedashStyle这样的选项。你必须在plotOptions.series.point.events.mouseOverplotOptions.series.point.events.mouseOut上写回调。请参见以下示例。

Highcharts.chart('container', {
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    plotOptions: {
        series: {
            states: {
                hover: {
                    enabled: true,
                    lineWidth: 5
                }
            }
        },
    },

    series: [{
    events: {
        mouseOver: function() {
          this.update({
            dashStyle: 'dash'
          });
        },
        mouseOut: function() {
          this.update({
            dashStyle: 'Solid'
          });
        }
      },
        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]
    }]
});

个字符

相关问题