$(function () { var d = [[1283576400000,103421],[1283490000000,103316],[1283403600000,101165],[1283317200000,99240],[1283230800000,105343],[1283144400000,112133],[1283058000000,115984],[1282971600000,114462]]; // first correct the timestamps - they are recorded as the daily // midnights in UTC+0100, but Flot always displays dates in UTC // so we have to add one hour to hit the midnights in the plot for (var i = 0; i < d.length; ++i) d[i][0] += 60 * 60 * 1000; // helper for returning the weekends in a period function weekendAreas(axes) { var markings = []; var d = new Date(axes.xaxis.min); // go to the first Saturday d.setUTCDate(d.getUTCDate() - ((d.getUTCDay() + 1) % 7)); d.setUTCSeconds(0); d.setUTCMinutes(0); d.setUTCHours(0); var i = d.getTime(); do { // when we don't set yaxis, the rectangle automatically // extends to infinity upwards and downwards markings.push({ xaxis: { from: i, to: i + 2 * 24 * 60 * 60 * 1000 } }); i += 7 * 24 * 60 * 60 * 1000; } while (i < axes.xaxis.max); return markings; } var options = { xaxis: { mode: "time", timeformat: "%m/%d"}, yaxis: { labelWidth: 0.1 }, selection: { mode: "x"}, grid: { markings: weekendAreas, color: "#410054"}, lines: { show: true, lineWidth: 2}, series: {color: "#3CE51A"} }; var plot = $.plot($("#placeholder"), [d], options); });