Reputation: 1141
I am using high charts to build a graph, which has multiple y axis and x axis date time based. But I see whatever format I am giving high charts for X axis it does not honour it the date is consecutive (example : july 01, july 02, july 03).The X axis is always giving format : date. month, although I specified date/month.
Can anyone help me with the config options.
$(function () {
$('#container').highcharts({
chart: {
type: 'spline'
},
title: {
text: 'Snow depth at Vikjafjellet, Norway'
},
subtitle: {
text: 'Irregular time data in Highcharts JS'
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
month: '%e/%b'
},
title: {
text: 'Date'
}
},
yAxis: [{
title: {
text: 'Snow depth (m)'
},
min: 0
}, {
opposite: true,
title: {
text: 'Snow height (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 2012-2013',
// 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.
yAxis: 1,
data: [
[Date.UTC(2016, 7, 01), 4],
[Date.UTC(2016, 7, 02), 5],
[Date.UTC(2016, 7, 03), 15]
]
}, {
name: 'Winter 2013-2014',
data: [
[Date.UTC(2016, 7, 01), 44],
[Date.UTC(2016, 7, 02), 5],
[Date.UTC(2016, 7, 03), 135]
]
}]
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<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>
Upvotes: 0
Views: 42
Reputation: 15639
Changing your dateTimeLabelFormats
to,
dateTimeLabelFormats: {
day: '%e / %b',
week: '%e / %b'
}
Will resolve the issue.
Working JSFiddle Demo: https://jsfiddle.net/6jo3gvfa/
Hope this helps!.
Upvotes: 1