Non-Identical Time Series in line chart - Javascript highcharts

Javascript examples for highcharts:Line Chart

Description

Non-Identical Time Series in line chart

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 () {//  w w w  .j a va  2 s .c o m
    myDataSeries1 = [
        ["2014-01-08", 1408],
        ["2014-01-09", 1357],
        ["2014-01-10", 1272],
        ["2014-01-11", 1625],
        ["2014-01-12", 1516],
        ["2014-01-13", 2002],
        ["2014-01-14", 2301]
    ];
    myDataSeries2 = [
        ["2014-01-21", 32],
        ["2014-01-22", 234],
        ["2014-01-23", 195],
        ["2014-01-24", 176],
        ["2014-01-25", 231]
    ];
    $.each(myDataSeries1, function (index, item) {
        item[0] = new Date(item[0]).getTime();
    });
    $.each(myDataSeries2, function (index, item) {
        item[0] = new Date(item[0]).getTime();
    });
    $('#container').highcharts({
        chart: {
            type: 'spline'
        },
        title: {
            text: 'Snow depth at Vikjafjellet, Norway'
        },
        subtitle: {
            text: 'Irregular time data in Highcharts JS'
        },
        xAxis: {
            type: 'datetime',
            dateTimeLabelFormats: { // don't display the dummy year
                month: '%e. %b',
                year: '%b'
            },
            title: {
                text: 'Date'
            }
        },
        yAxis: {
            title: {
                text: 'Snow depth (m)'
            },
            min: 0
        },
        tooltip: {
            headerFormat: '<b>{series.name}</b><br>',
            pointFormat: '{point.x:%e. %b}: {point.y:.2f} m'
        },
        series: [{
            name: 'MyData1',
            data: myDataSeries1
        }, {
            name: 'MyData2',
            data: myDataSeries2
        }]
    });
});

      </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