Highchart - datetime
Highcharts uses 1970 when date is null !
by Ben Clayton
HTML
<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>
JavaScript
$(function () {
Highcharts.chart('container', {
chart: {
type: 'spline'
},
title: {
text: 'Snow depth at Vikjafjellet, Norway'
},
subtitle: {
text: 'Irregular time data in Highcharts JS'
},
xAxis: {
type: 'datetime',
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'
},
plotOptions: {
spline: {
marker: {
enabled: true
}
}
},
series: [{
name: 'Winter a',
data: [
[null, 2],
[Date.UTC(2015, 1, 21), 0],
[Date.UTC(2015, 9, 28), 1]
]
}, {
name: 'Winter b',
data: [
[Date.UTC(2015, 8, 21), 0],
[Date.UTC(2015, 9, 27), 1.3]
]
}, {
name: 'Winter c',
data: [
[Date.UTC(2015, 9, 21), 0.4],
[Date.UTC(2015, 11, 25), 1.4]
]
}]
});
});