i'm trying to build a spline with an errorbar with xAxis based on irregular time instead of using categories but i got some troubles.
This is an example: http://jsfiddle.net/Zj2Lp/4/
Any idea how to achieve that?
Thank you in advance
Code here:
var chart;
$(function() {
$('#container').highcharts({
chart: {
zoomType: 'xy',
},
title: {
text: 'Temperature vs Rainfall'
},
xAxis: [{
type: 'datetime'
}],
/*
xAxis: [{
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
}],
*/
yAxis: [{ // Primary yAxis
labels: {
format: '{value} °C',
style: {
color: Highcharts.getOptions().colors[0]
}
},
title: {
text: 'Temperature',
style: {
color: Highcharts.getOptions().colors[0]
}
}
}],
tooltip: {
shared: true
},
series: [{
name: 'Temperature',
type: 'spline',
data: [
[Date.UTC(2014, 5, 10), 7.0],
[Date.UTC(2014, 5, 11), 26.5],
[Date.UTC(2014, 5, 12), 9.6]
],
tooltip: {
pointFormat: '<span style="font-weight: bold; color: {series.color}">{series.name}</span>: <b>{point.y:.1f}°C</b> '
}
}, {
name: 'Temperature error',
type: 'errorbar',
data: [
[Date.UTC(2014, 5, 10), [6, 8]],
[Date.UTC(2014, 5, 11), [26.1, 27.8]],
[Date.UTC(2014, 5, 12), [7.6, 10.0]]
],
tooltip: {
pointFormat: '(error range: {point.low}-{point.high}°C)<br/>'
}
}]
});
The problem is the format you've used for the data
in your errorbar
series. The correct format is using a two-dimensional array. Not a three dimensional array, like you use in your code.
You had each point in the series being:
[Date.UTC(2014, 5, 10), [6, 8]]
It should be:
[Date.UTC(2014, 5, 10), 6, 8]
Here's the final updated errorbar
series:
{
name: 'Temperature error',
type: 'errorbar',
data: [
[Date.UTC(2014, 5, 10), 6, 8],
[Date.UTC(2014, 5, 11), 26.1, 27.8],
[Date.UTC(2014, 5, 12), 7.6, 10.0]
],
tooltip: {
pointFormat: '(error range: {point.low}-{point.high}°C)<br/>'
}
}
And here's a updated JFiddle to see the result.