【问题标题】:How to plot line in highcharts on charts click event?如何在图表点击事件的高图表中绘制线条?
【发布时间】:2013-07-14 19:42:51
【问题描述】:

是否可以在图表的点击事件上绘制一条线?

Chart Click Event

chart: {
        events: {
            click: function(event) {
                alert ('x: '+ event.xAxis[0].value  +', y: '+
                      event.chartY );
                 var chart = event.xAxis[0];
                            chart.removePlotLine('plot-line-1');
                            chart.addPlotLine({
                                value: event.chartX,
                                color: '#FF0000',
                                width: 2,
                                id: 'plot-line-1'
                            });
            }
        }        
    },

我最初在 highcharts 的 plotoptions 点击事件上做了同样的事情。现在,使用图表点击事件做同样的事情?但无法获取系列 xaxis 对象。

【问题讨论】:

    标签: highcharts


    【解决方案1】:

    成功了!必须阅读 highcharts 文档... :-)

    Working LINK

     chart: {
            events: {
                click: function (event) {
                    var chart = this.xAxis[0];
                    chart.removePlotLine('plot-line-1');
                    chart.addPlotLine({
                        value: event.xAxis[0].value,
                        color: '#FF0000',
                        width: 2,
                        id: 'plot-line-1'
                    });
                }
            }
    

    【讨论】:

      猜你喜欢
      • 2017-01-26
      • 2019-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多