Highcharts => Getting the id of a point when clicking on a line chart

后端 未结 6 1455
既然无缘
既然无缘 2020-12-29 07:25

I am building a line chart and I would like, when I click on a point of the line, to display a popup containing some data about this point. The issue I try to resolve is to

6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-29 08:06

    To return the 'ID' of the selected point on the chart use the 'X' value:

    plotOptions: {
        series: {
            cursor: 'pointer',
            events: {
                click: function(event) {
                       // Log to console
                    console.log(event.point);
                    alert(this.name +' clicked\n'+
                          'Alt: '+ event.altKey +'\n'+
                          'Control: '+ event.ctrlKey +'\n'+
                          'Shift: '+ event.shiftKey +'\n'+
                          'Index: '+ event.point.x);
                }
            }
        }
    },
    

    See an example here: http://jsfiddle.net/engemasa/mxRwg/

提交回复
热议问题