flot UTC v local time
http://stackoverflow.com/questions/11681669/utc-woes-flot-x-axis-time-wrong
by ryleyb
HTML
<script src="http://people.iola.dk/olau/flot/jquery.flot.js"></script>
<div id="placeholder" style="width:600px;height:300px;"></div>
JavaScript
var series = [{
"label": "24 Hour Overview",
"data": [[1343283113000, "111"], [1343286597000, "111"], [1343290220000, "111"], [1343293802000, "111"], [1343297377000, "111"], [1343300843000, "111"], [1343304504000, "111"], [1343308105000, "111"], [1343311724000, "111"], [1343315331000, "111"], [1343322489000, "111"], [1343326080000, "111"], [1343329669000, "111"], [1343333296000, "111"], [1343336882000, "111"], [1343340493000, "111"], [1343344094000, "111"], [1343347683000, "111"], [1343351299000, "111"], [1343355015000, "111"], [1343358535000, "112"], [1343362132000, "112"], [1343365704000, "112"]],
"color": "#FFAA42"}];
var length = series.length;
var finalData = series;
var options = {
lines: {
show: true
},
legend: {
show: false
},
points: {
show: true,
hoverable: true
},
grid: {
hoverable: true,
clickable: true
},
xaxis: {
mode: "time",
timeformat: "%d/%m/%y %H:%M"
},
yaxis: {
minTickSize: "1",
tickDecimals: "0"
}
};
$.plot($('#placeholder'), finalData, options);
var previousPoint = null;
$("#placeholder").bind("plothover", function(event, pos, item) {
if (item) {
if (previousPoint != item.dataIndex) {
previousPoint = item.dataIndex;
$("#graph_info").remove();
var x = item.datapoint[0],
y = item.datapoint[1].toFixed(2);
var date = new Date(x + (7 * 60 * 60 * 1000));
var hour = date.getHours();
var min = date.getMinutes();
var msg = hour + ":" + min + ", " + y;
if (min < 10) msg = hour + ":" + "0" + min + ", " + y;
showToolTip(item.pageX, item.pageY, msg);
}
}
else {
$("#graph_info").remove();
previousPoint = null;
}
});
function showToolTip(x, y, contents) {
$('<div id="graph_info">' + contents + '</div>').css({
position: 'absolute',
...