I’ve isolated an end case with jqPlot that causes it to “crash” (halt indefinitely) my entire page’s javascript. This happens when I use the DateAxisRenderer in a line chart with a single value like so:
(function() {
$(function() {
var data, now, plot1;
now = new Date;
// single data point in the series:
data = [[now, 1]];
return plot1 = $.jqplot("plotTarget", [data], {
axes: {
xaxis: {
// if I remove this renderer, the "crash" does not happen:
renderer: $.jqplot.DateAxisRenderer
}
}
});
});
}).call(this);
Why does this happen? is this a bug in jqPlot or am I doing something wrong?
Also noticed: If I add more values with the same date into the series, the same problem occurs. If I add more values with different dates, the problem goes away.
I’m using jQuery v1.6.4, jqPlot v1.0.0b2_r1012 and rendering on Firefox 8.0.1.
Glimpsing at the code of the DateAxisRenderer shows that the plugin tries to compute a minimum and maximum value to determine the ticks. This simply suggests that the author implies that a series consists of a minimum of two datapoints. And this is not stated in the docs or checked in the code thats why the plugin “crashes”.
In the jqplot Bugtracking list the bug is already filed (4 days ago on Jan 21st 2012).