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).
I also had faced this issue today, what surprised me was the same code worked with jsfiddle where I used scripts from Bitbucket.
I was using jqplot with ASP.NET MVC and had downloaded the jqplot scripts using nuget extension, it turned out that extension had downloaded the older version of jqplot which caused the problem.
So, simply changing my old DateAxisRender.js to the new updated one from here, solved my problem or you can also download the latest version from this page.
I had created a demo at jsfiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With