Flot works on:
Firefox 2.x+
Safari 3.0+
Opera 9.5+
Konqueror 4.x+
Internet Explorer 6+ (the excanvas
Javascript emulation helper is used for
IE < 9)
A lot of plugins
and examples
Plugins -
http://code.google.com/p/flot/wiki/Plugins
Bubble charts -
https://github.com/ubermajestix/flot-plugins
Usage examples:
http://code.google.com/p/flot/wiki/FlotUsage
And now to the main
part...
var weekdayNames = "Sunday Monday Tuesday Wednesday Thursday Friday
Saturday".split(" ");
var shortMonthNames = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov
Dec".split(" ");
$.get('/manage/get_statistics_usage_data', {}, function(data){
var stat_data = jQuery.parseJSON(data);
//variables init
var now = new Date().getTime() + stat_data.time_offset;
var weekday = new Date(now).getDay();
var month = new Date(now).getMonth();
...
And now to the main
part...
//building weekly data
var api_calls_points = stat_data.api_calls_weekly;
var bandwidth_points = stat_data.bandwidth_weekly;
for(var i=0; i<api_calls_points.length; i++) {
graph2_ticks.push([7-i, weekdayNames[(weekday+7-i)%7]]);
api_calls_weekly.push([i, api_calls_points[i]]);
bandwidth_weekly.push([i, bandwidth_points[i]]);
}
...
//building yearly data
var api_calls_points = stat_data.api_calls_yearly;
var bandwidth_points = stat_data.bandwidth_yearly;
for(var i=0; i<api_calls_points.length; i++) {
graph4_ticks.push([12-i, shortMonthNames[(month+12-i)%12]]);
api_calls_yearly.push([i, api_calls_points[i]]);
bandwidth_yearly.push([i, bandwidth_points[i]]);
}
And now to the main
part...
var options2 = {
legend: {
position: "ne",
container: $("#graph2_legend")
}, xaxis: {
ticks: graph2_ticks
}, yaxis: {
min: 0,
tickDecimals: 0 //only whole numbers
}, grid: { hoverable: true }
};
xaxis: { //in case of time axis
mode: "time",
timeformat: "%H:%M"
},
And now to the main
part...
var usage_plot2 = $.plot($("#graph2"), [
{
data: api_calls_weekly,
label: "API calls",
lines: { show: true }
},
{
label: "Bandwidth (KB)",
data: bandwidth_weekly,
lines: { show: true }
},
], options2);