Handling unix timestamp - Javascript highcharts

Javascript examples for highcharts:Chart Configuration

Description

Handling unix timestamp

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://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <script type="text/javascript" src="https://code.highcharts.com/highcharts.js"></script> 
      <script type="text/javascript">
    $(window).load(function(){/*from   w  w w .j av  a2  s  . co  m*/
var data = {
    "a": [
        [
            133409520000,
            1
        ],
        [
            133435440000,
            2
        ]
    ],
    "b": [
        [
            133400880000,
            1
        ],
        [
            133435440000,
            1
        ]
    ]
}
var options = {
    chart: { renderTo: 'graph' },
    xAxis: { type: 'datetime' },
    series: []
};
var a = {
    name: 'a',
    data: []
};
var b = {
    name: 'b',
    data: []
};
$.each(data, function(key, value) {
    if (key == 'a') {
        $.each(value, function(k, v) {
            a.data.push(v);
        });
    } else {
        $.each(value, function(k, v) {
            b.data.push(v);
        });
    }
});
options.series.push(a, b);
var chart = new Highcharts.Chart(options);
    });

      </script> 
   </head> 
   <body> 
      <div id="graph"></div>  
   </body>
</html>

Related Tutorials