displaying series pushed from JSON - Javascript highcharts

Javascript examples for highcharts:Chart Json Data

Description

displaying series pushed 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.8.3.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){// www .j av  a 2s . co  m
$(document).ready(function() {
    var data = [];
    $.getJSON('http://api.cosm.com/v2/feeds/79903/datastreams/Temperature.json?start=2012-10-31T14:01:46Z&end=2012-11-03T17:01:46Z&interval=3600?key=dNSiSvXZtR6QBUqbzll4CCgnngGSAKxIQVFSeXBneGpqWT0g', function(inData) {
        var xval = new Date();
        dateStart = Date.parse(inData.datapoints[0].at);
        for (i = 0; i < inData.datapoints.length; i++) {
            var yval = parseFloat(inData.datapoints[i].value);
            xval = Date.parse(inData.datapoints[i].at);
            var x = [xval, yval];
            data.push(x);
        }
        //data.push({x: xval, y:yval});
        var chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container'
            },
            xAxis: {
                type: 'datetime'
            },
            series: [{
                data: data}]
        });
    });
    function blah() {
        for (i = 0; i < 100; i++) {
            var k = Math.random() * 50;
            data.push(i + k);
        }
    }
});
    });

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

Related Tutorials