$(function() { if (typeof sufia_item_stats === "undefined") { return; } function weekendAreas(axes) { var markings = [], 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(); // when we don't set yaxis, the rectangle automatically // extends to infinity upwards and downwards do { 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", tickLength: 5 }, yaxis: { tickDecimals: 0, min: 0 }, series: { lines: { show: true, fill: true }, points: { show: true, fill: true } }, selection: { mode: "x" }, grid: { hoverable: true, clickable: true, markings: weekendAreas } }; var plot = $.plot("#usage-stats", sufia_item_stats, options); $("
").css({ position: "absolute", display: "none", border: "1px solid #bce8f1", padding: "2px", "background-color": "#d9edf7", opacity: 0.80 }).appendTo("body"); $("#usage-stats").bind("plothover", function (event, pos, item) { if (item) { date = new Date(item.datapoint[0]); months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] $("#tooltip").html("" + item.series.label + ": " + item.datapoint[1] + "