/** Graphs : Flot graphs-flot.html loadScript(plugin_path + "chart.flot/jquery.flot.min.js", function(){ loadScript(plugin_path + "chart.flot/jquery.flot.resize.min.js", function(){ loadScript(plugin_path + "chart.flot/jquery.flot.time.min.js", function(){ loadScript(plugin_path + "chart.flot/jquery.flot.fillbetween.min.js", function(){ loadScript(plugin_path + "chart.flot/jquery.flot.orderBars.min.js", function(){ loadScript(plugin_path + "chart.flot/jquery.flot.pie.min.js", function(){ loadScript(plugin_path + "chart.flot/jquery.flot.tooltip.min.js", function(){ // demo js script loadScript("assets/js/view/demo.graphs.flot.js"); }); }); }); }); }); }); }); ------------------------------------------------------------------------------------------ 01. SALES CHART 02. SIN CHART 03. BAR CHART 04. BAR CHART HORIZONTAL 05. PIE CHART 06. STATS CHART 07. REALTIME CHART http://www.flotcharts.org/flot/examples/ ************************************************* **/ jQuery(window).ready(function() { _flot(); }); function _flot() { /* DEFAULTS FLOT COLORS */ var $color_border_color = "#eaeaea"; /* light gray */ $color_grid_color = "#dddddd" /* silver */ $color_main = "#E24913"; /* red */ $color_second = "#6595b4"; /* blue */ $color_third = "#FF9F01"; /* orange */ $color_fourth = "#7e9d3a"; /* green */ $color_fifth = "#BD362F"; /* dark red */ $color_mono = "#000000"; /* black */ /** 01. SALES CHART ******************************************* **/ if (jQuery("#flot-sales").length > 0) { var d = [[1196463600000, 0], [1196550000000, 0], [1196636400000, 0], [1196722800000, 77], [1196809200000, 3636], [1196895600000, 3575], [1196982000000, 2736], [1197068400000, 1086], [1197154800000, 676], [1197241200000, 1205], [1197327600000, 906], [1197414000000, 710], [1197500400000, 639], [1197586800000, 540], [1197673200000, 435], [1197759600000, 301], [1197846000000, 575], [1197932400000, 481], [1198018800000, 591], [1198105200000, 608], [1198191600000, 459], [1198278000000, 234], [1198364400000, 1352], [1198450800000, 686], [1198537200000, 279], [1198623600000, 449], [1198710000000, 468], [1198796400000, 392], [1198882800000, 282], [1198969200000, 208], [1199055600000, 229], [1199142000000, 177], [1199228400000, 374], [1199314800000, 436], [1199401200000, 404], [1199487600000, 253], [1199574000000, 218], [1199660400000, 476], [1199746800000, 462], [1199833200000, 500], [1199919600000, 700], [1200006000000, 750], [1200092400000, 600], [1200178800000, 500], [1200265200000, 900], [1200351600000, 930], [1200438000000, 1200], [1200524400000, 980], [1200610800000, 950], [1200697200000, 900], [1200783600000, 1000], [1200870000000, 1050], [1200956400000, 1150], [1201042800000, 1100], [1201129200000, 1200], [1201215600000, 1300], [1201302000000, 1700], [1201388400000, 1450], [1201474800000, 1500], [1201561200000, 546], [1201647600000, 614], [1201734000000, 954], [1201820400000, 1700], [1201906800000, 1800], [1201993200000, 1900], [1202079600000, 2000], [1202166000000, 2100], [1202252400000, 2200], [1202338800000, 2300], [1202425200000, 2400], [1202511600000, 2550], [1202598000000, 2600], [1202684400000, 2500], [1202770800000, 2700], [1202857200000, 2750], [1202943600000, 2800], [1203030000000, 3245], [1203116400000, 3345], [1203202800000, 3000], [1203289200000, 3200], [1203375600000, 3300], [1203462000000, 3400], [1203548400000, 3600], [1203634800000, 3700], [1203721200000, 3800], [1203807600000, 4000], [1203894000000, 4500]]; for (var i = 0; i < d.length; ++i) { d[i][0] += 60 * 60 * 1000; } 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", tickLength : 5 }, series : { lines : { show : true, lineWidth : 1, fill : true, fillColor : { colors : [{ opacity : 0.1 }, { opacity : 0.15 }] } }, //points: { show: true }, shadowSize : 0 }, selection : { mode : "x" }, grid : { hoverable : true, clickable : true, tickColor : $color_border_color, borderWidth : 0, borderColor : $color_border_color, }, tooltip : true, tooltipOpts : { content : "Your sales for %x was $%y", dateFormat : "%y-%0m-%0d", defaultTheme : false }, colors : [$color_second], }; var plot = jQuery.plot(jQuery("#flot-sales"), [d], options); } /** 02. SIN CHART ******************************************* **/ if (jQuery("#flot-sin").length > 0) { var sin = [], cos = []; for (var i = 0; i < 16; i += 0.5) { sin.push([i, Math.sin(i)]); cos.push([i, Math.cos(i)]); } var plot = jQuery.plot(jQuery("#flot-sin"), [{ data : sin, label : "sin(x)" }, { data : cos, label : "cos(x)" }], { series : { lines : { show : true }, points : { show : true } }, grid : { hoverable : true, clickable : true, tickColor : $color_border_color, borderWidth : 0, borderColor : $color_border_color, }, tooltip : true, tooltipOpts : { //content : "Value $x Value $y", defaultTheme : false }, colors : [$color_second, $color_fourth], yaxis : { min : -1.1, max : 1.1 }, xaxis : { min : 0, max : 15 } }); jQuery("#flot-sin").bind("plotclick", function(event, pos, item) { if (item) { jQuery("#clickdata").text("You clicked point " + item.dataIndex + " in " + item.series.label + "."); plot.highlight(item.series, item.datapoint); } }); } /** 03. BAR CHART ******************************************* **/ if (jQuery("#flot-bar").length > 0) { var data1 = []; for (var i = 0; i <= 12; i += 1) data1.push([i, parseInt(Math.random() * 30)]); var data2 = []; for (var i = 0; i <= 12; i += 1) data2.push([i, parseInt(Math.random() * 30)]); var data3 = []; for (var i = 0; i <= 12; i += 1) data3.push([i, parseInt(Math.random() * 30)]); var ds = new Array(); ds.push({ data : data1, bars : { show : true, barWidth : 0.2, order : 1, } }); ds.push({ data : data2, bars : { show : true, barWidth : 0.2, order : 2 } }); ds.push({ data : data3, bars : { show : true, barWidth : 0.2, order : 3 } }); //Display graph jQuery.plot(jQuery("#flot-bar"), ds, { colors : [$color_second, $color_fourth, "#666", "#BBB"], grid : { show : true, hoverable : true, clickable : true, tickColor : $color_border_color, borderWidth : 0, borderColor : $color_border_color, }, legend : true, tooltip : true, tooltipOpts : { content : "%x = %y", defaultTheme : false } }); } /** 04. BAR CHART HORIZONTAL ******************************************* **/ if (jQuery("#flot-bar-horizontal").length > 0) { //Display horizontal graph var d1_h = []; for (var i = 0; i <= 3; i += 1) d1_h.push([parseInt(Math.random() * 30), i]); var d2_h = []; for (var i = 0; i <= 3; i += 1) d2_h.push([parseInt(Math.random() * 30), i]); var d3_h = []; for (var i = 0; i <= 3; i += 1) d3_h.push([parseInt(Math.random() * 30), i]); var ds_h = new Array(); ds_h.push({ data : d1_h, bars : { horizontal : true, show : true, barWidth : 0.2, order : 1, } }); ds_h.push({ data : d2_h, bars : { horizontal : true, show : true, barWidth : 0.2, order : 2 } }); ds_h.push({ data : d3_h, bars : { horizontal : true, show : true, barWidth : 0.2, order : 3 } }); // display graph jQuery.plot(jQuery("#flot-bar-horizontal"), ds_h, { colors : [$color_second, $color_fourth, "#666", "#BBB"], grid : { show : true, hoverable : true, clickable : true, tickColor : $color_border_color, borderWidth : 0, borderColor : $color_border_color, }, legend : true, tooltip : true, tooltipOpts : { content : "%x = %y", defaultTheme : false } }); } /** 05. PIE CHART ******************************************* **/ if (jQuery("#flot-pie").length > 0) { var data_pie = []; var series = Math.floor(Math.random() * 10) + 1; for (var i = 0; i < series; i++) { data_pie[i] = { label : "Series" + (i + 1), data : Math.floor(Math.random() * 100) + 1 } } jQuery.plot(jQuery("#flot-pie"), data_pie, { series : { pie : { show : true, innerRadius : 0.5, radius : 1, label : { show : false, radius : 2 / 3, formatter : function(label, series) { return '