Highcharts Demo

author(s): Torstein Hønsi

by Dilip Prajapati

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/series-label.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>

JavaScript

Highcharts.chart('container', {
    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  %Y, %H:%M} = {point.y:.2f} m'
    },

    plotOptions: {
        spline: {
            marker: {
                enabled: true
            }
        }
    },

    colors: ['#6CF', '#39F', '#06C', '#036', '#000'],

    // Define the data points. All series have a dummy year
    // of 1970/71 in order to be compared on the same x axis. Note
    // that in JavaScript, months start at 0 for January, 1 for February etc.
    series: [{
        name: "Winter 2014-2015",
        data: [
            [Date.UTC(1970, 10, 25, 05, 40), 0],
            [Date.UTC(1970, 11,  6, 05, 40), 0.25],
          
            [Date.UTC(1971, 0, 17, 05, 40), 2.55],
            [Date.UTC(1971, 0, 24, 05, 40), 2.62],
     
            [Date.UTC(1971, 2, 24), 2.6],
            [Date.UTC(1971, 3,  1), 2.81],
        
  
            [Date.UTC(1971, 5, 29, 05, 40), 0.67],

            [Date.UTC(1971, 6,  4, 05, 40), 0]
        ]
    }, {
        name: "Winter 2015-2016",
        data: [
            [Date.UTC(1970, 10,  9, 05, 40), 0],
            [Date.UTC(1970, 10, 15, 05, 40), 0.23],

            [Date.UTC(1970, 11, 15, 05, 40), 0.73],
    
            [Date.UTC(1970, 11, 25, 05, 40), 1.07],

            [Date.UTC(1971, 0, 25, 05, 40), 1.03],

            [Date.UTC(1971, 1,  5, 05, 40), 1.77],

            [Date.UTC(1971, 4, 29, 05, 40), 0.85],
           ...