javascript - 图表初始化后如何更改 highcharts 事件

标签 javascript highcharts

图表初始化后如何更改 highcharts 事件?

<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);
}

我想如上所述重写 mouseOver 事件,但似乎没有效果。 对于任何可以提供帮助的人,我将非常感激。

最佳答案

不支持实时更新plotOptions。 jsFiddle .

您可以通过这种方式更新单系列选项:

chart.series[0].update({
  point: {
    events: {
      mouseOver: function() {
        $('#report').html('outer x: ' + this.x + ', y: ' + this.y);
      }
    }
  } 
});

关于javascript - 图表初始化后如何更改 highcharts 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19827167/

相关文章:

javascript - 检查元素是否正在动画 CSS3

php - 柱形图中系列的不同点宽度

Highcharts - 仅在 x 轴上显示年份并停止自动格式化

javascript - 同一页面中的多个图表 Highchart

javascript - 有没有办法在没有真正的 onclick 事件的情况下使用 onclick ?

javascript - JS 持续加载直到img src改变

javascript - SessionStorage,只获取最后的值

javascript - Webpack 不会自动编译 React 文件中代码的更改

javascript - 只有一个段的 HighCharts 饼图不显示标签

javascript - 以编程方式更改 Highmaps 中的形状颜色