access the value of a custom attribute in data from column chart - Javascript highcharts

Javascript examples for highcharts:Column Chart

Description

access the value of a custom attribute in data from column chart

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript">
$(function () {/*w  w w. j  av a  2  s  .  c om*/
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        xAxis: {
            categories: ['Green', 'Pink']
        },
        series: [{
            data: [{
                name: 'Point 1',
                color: '#00FF00',
                id: 8,
                y: 1
            }, {
                name: 'Point 2',
                color: '#FF00FF',
                id: 9,
                y: 5
            }, {
                name: 'Point 1',
                color: '#00FF00',
                id: 7,
                y: 1
            }, {
                name: 'Point 2',
                color: '#FF00FF',
                id: 6,
                y: 5
            }]
        }]
    }, function (chart) {
        var max = chart.yAxis[0].dataMax,
            maxIndex = chart.series[0].yData.indexOf(max),
            data = chart.series[0].data;
        if(maxIndex > -1) {
            console.log("max = " + max, 'id = ' + data[maxIndex].id);
        }
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <div id="container" style="height: 400px"></div>  
   </body>
</html>

Related Tutorials