Reputation: 788
I have a very basic 'line' weekly date graphic. I just need the date on x-axis to start the on given day of my first point. I have specified pointStart: Date.UTC(2018, 09, 25) but it showing different week in a different month? How can I display week from given date in x-axis?
$('#container').highcharts({
chart: {
type: 'line'
},
credits : {
enabled : false
},
title: {
text: false
},
xAxis: {
tickInterval: 7 * 24 * 3600 * 1000,
type: 'datetime',
startOnTick: true,
startOfWeek: 0,
labels: {
format: '{value:%d/%m/%Y}',
rotation: -45,
y: 30,
align: 'center'
}
},
yAxis: {
min: 0,
title: {
text: 'HH'
}
},
plotOptions: {
series: {
pointStart: Date.UTC(2018, 09, 25),
pointInterval: 7 * 24 * 3600 * 1000
}
},
series: [
{
name: 'Curva Tardía',
data: [18, 27, 36, 36, 10]
}, {
name: 'Curva Temprana',
data: [9, 18, 27, 27, 90]
},{
name: 'Curva Real',
data: [0, 36, 45, 89, 100]
}
]
});
Upvotes: 0
Views: 1242
Reputation: 39139
You need to use startOfWeek
option:
xAxis: {
startOfWeek: 4
}
Live demo: http://jsfiddle.net/BlackLabel/nL4vuz5f/
API: https://api.highcharts.com/highcharts/xAxis.startOfWeek
Upvotes: 1
Reputation: 5803
Easy to make mistake, in Date.UTC
, month is a 0 based index, which means initializing the function with 09 means it is setting month to October and not September.
By setting Date.UTC(2018, 08, 25)
you will get the date you expect to be there:
$('#container').highcharts({
chart: {
type: 'line'
},
credits : {
enabled : false
},
title: {
text: false
},
xAxis: {
tickInterval: 7 * 24 * 3600 * 1000,
type: 'datetime',
startOnTick: true,
startOfWeek: 0,
labels: {
format: '{value:%d/%m/%Y}',
rotation: -45,
y: 30,
align: 'center'
}
},
yAxis: {
min: 0,
title: {
text: 'HH'
}
},
plotOptions: {
series: {
pointStart: Date.UTC(2018, 08, 25),
pointInterval: 7 * 24 * 3600 * 1000
}
},
series: [
{
name: 'Curva Tardía',
data: [18, 27, 36, 36, 10]
}, {
name: 'Curva Temprana',
data: [9, 18, 27, 27, 90]
},{
name: 'Curva Real',
data: [0, 36, 45, 89, 100]
}
]
});
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
Upvotes: 1