I'm struggling with Highcharts. I'm creating a bar chart with on the x-axis datetime values. These values were constructed from a JSON source (example: http://gist.github.com/297981). In essence it turns ["2009-10-23", "123"] into [Date.UTC(2009, 10, 23), 123].
Upon rendering something is going wrong. Firefox warns me of an unresponsive script and I need to kill it.
The problem is somewhere with the Date.UTC labels because when I remove the custom dataParser the chart does render (but is basically useless). Am I doing something wrong?
Code: Select all
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
defaultSeriesType: 'column',
margin: [50, 150, 60, 80]
},
title: {
text: 'texts/ calls <strong>created</strong> per day',
style: {
margin: '10px 100px 0 0' // center it
}
},
subtitle: {
text: 'Source: Backup database',
style: {
margin: '0 100px 0 0' // center it
}
},
xAxis: {
type: 'datetime',
title: {
text: 'Date'
},
max: 1000
},
yAxis: {
title: {
text: 'Count'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}],
max: 20000,
min: 0
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
this.x +': '+ this.y;
}
},
legend: {
layout: 'vertical',
style: {
left: 'auto',
bottom: 'auto',
right: '10px',
top: '100px'
}
},
series: [{
name: 'texts',
dataURL: 'data/texts.json',
dataParser: function(data) {
var double_array = eval(data);
result = [];
for(var i = 0; i < double_array.length ;i++) {
date = double_array[i][0].split("-");
real_date = Date.UTC(date[0], date[1], date[2])
result.push([real_date, parseInt(double_array[i][1])]);
}
return result;
}
}
});