Flot jQuery プラグインを使用して、Web サイトでグラフをレンダリングしています。Chrome の最新バージョンでは完全に動作しますが、Firefox と Internet Explorer では失敗するようです。Firefox のバージョン 21 と Internet Explorer の 10 を使用しています。関連するコードは次のとおりです。
$(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');
});
グラフは、Chrome で (正しく) 次のようにレンダリングされます。
ただし、Firefox と Internet Explorer では次のようになります。
以前にこの問題に遭遇し、原因を知っている人はいますか?
また、Firefox と IE のどちらにもコンソール エラーはなく、どちらも AJAX 要求を行っており、開発者ツールのネットワーク タブで確認した正しいデータを取得していることにも言及する価値があります。
編集:値を次のようにハードコードすると、次のように言う価値もあります。
$.plot($('#server-stats'), [{label: 'Players', data: [[10, 10], [20, 20]]}, {label: 'Ping (ms)', data: [[30, 30], [40, 40]]}], {
Firefox と IE と Chrome で動作します。