Load data from Json - Javascript highcharts

Javascript examples for highcharts:Chart Data

Description

Load data from Json

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> 
      <script type="text/javascript">
$(function () {// www .  j  a  v a  2 s  . c om
    var categories = [],
        series = [
            {
                name: "BUY",
                data: []
            },{
                name: "SELL",
                data: []
            }
        ];
    var json = [{
        "Id": 16846,
        "AXA": 2.2090,
        "BXB": 2.2270,
        "HMS": "08:17:05"
    }, {
        "Id": 16847,
        "AXA": 2.2091,
        "BXB": 2.2271,
        "HMS": "08:17:21"
    }, {
        "Id": 16848,
        "AXA": 2.2087,
        "BXB": 2.2271,
        "HMS": "08:18:02"
    }, {
        "Id": 16852,
        "AXA": 2.2090,
        "BXB": 2.2270,
        "HMS": "08:42:00"
    }];
    $.each(json, function (i, p){
        series[0].data.push(p.AXA);
        series[0].data.push(p.BXB);
        categories.push(p.HMS);
    });
    $('#container').highcharts({
        xAxis: {
            categories: categories
        },
        series: series
    });
});

      </script> 
   </head> 
   <body> 
      <script src="https://code.highcharts.com/highcharts.js"></script> 
      <script src="https://code.highcharts.com/modules/exporting.js"></script> 
      <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>  
   </body>
</html>

Related Tutorials