Selecting a point by ID using Highcharts

前端 未结 1 1729
栀梦
栀梦 2021-01-13 11:26

Using Highcharts, how can I select a point using it\'s id? For example, if I create a chart using the following code:

 chart1 = new Highcharts.Chart({
               


        
相关标签:
1条回答
  • 2021-01-13 11:44

    You can set an id for each point you want to get.

    series: [{
        name: 'Jane',
        data: [{
            'name': 'Point1',
            'id': 'point1',
            'x': 1,
            'y': 2
        }, {
            'name': 'Point2',
            'id': 'point2',
            'x': 2,
            'y': 5
        }]
    }, {
        name: 'John',
        data: [5, 7, 3]
    }]
    

    Then you can get the point by the following code.

    // assuming that chart is your chart var
    chart.get('point1');
    

    demo

    Or if you don't want to set an id you can simple loop thrue points to compare the name you want to find with the point name.

    Reference:

    • http://api.highcharts.com/highstock#object-Chart
    0 讨论(0)
提交回复
热议问题