I'm using the Flot jQuery plugin to render graphs on my website. It works perfectly in the latest versions of Chrome however seems to fail when in Firefox and Internet Explorer. I'm using version 21 of Firefox and 10 of Internet Explorer. Here's the relevant code:
$(document).ready(function() {
var currentURL = window.location;
// This will hold our plot data
var playersPlots = [];
var pingPlots = [];
// Make an AJAX request to get the server stats
$.get(currentURL + '/stats.json', function(data) {
$.each(data.stats, function(index, value) {
playersPlots.push([new Date(value.ServerStat.created).getTime(), value.ServerStat.players]);
pingPlots.push([new Date(value.ServerStat.created).getTime(), value.ServerStat.ping]);
});
$.plot($('#server-stats'), [{label: 'Players', data: playersPlots}, {label: 'Ping (ms)', data: pingPlots}], {
xaxis: {
mode: 'time',
timeformat: '%I:%M',
'tickSize': [3, "hour"]
}
});
}, 'json');
});
The graphs renders like this (correctly) under Chrome:
But like this under Firefox and Internet Explorer:
Has anyone ran into this issue before and knows the cause?
It's also worth mentioning that there are no console errors in either Firefox nor IE, and they're both making the AJAX request and getting back the correct data which I've confirmed by looking in the network tab of the developer tools.
Edit: Also worth saying that if I hardcode the values like so:
$.plot($('#server-stats'), [{label: 'Players', data: [[10, 10], [20, 20]]}, {label: 'Ping (ms)', data: [[30, 30], [40, 40]]}], {
it works in Firefox and IE and Chrome.
This was happening because of my date format. By default MySQL returns a DATETIME as YYYY-MM-DD HH:MM:SS
, when it needed to be YYYY-MM-DDTHH:MM:SS
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