diff --git a/var/www/static/js/moduleTrending.js b/var/www/static/js/moduleTrending.js new file mode 100644 index 00000000..10487a5b --- /dev/null +++ b/var/www/static/js/moduleTrending.js @@ -0,0 +1,174 @@ +/* Already defined variable (Before the input) +* +* var chart_1_num_day = 5; +* var chart_2_num_day = 15; +* +*/ + +var pie_threshold = 0.05 +var options = { + series: { pie: { show: true, + radius: 3/5, + combine: { + color: '#999', + threshold: pie_threshold + }, + label: { + show: true, + radius: 1, + formatter: labelFormatter, + background: { + opacity: 0.5, + color: '#000' + } + } + } + }, + grid: { hoverable: true, clickable: true }, + legend: { show: false }, + }; + +function labelFormatter(label, series) { + return "
" + + label + "
" + Math.round(series.percent) + "%
"; +} + + +function plot_top_graph(module_name){ + + /**** Pie Chart ****/ + + // moduleCharts is used the decide the url to request data + var moduleCharts = "size" == module_name ? "sizeCharts" : ("number" == module_name ? "numberChart" : "moduleCharts"); + var tot_sum = 0; // used to detect elements putted in 'Other' pie's part + var data_other = []; // used to detect elements putted in 'Other' pie's part + + + $.getJSON($SCRIPT_ROOT+"/_"+moduleCharts+"?moduleName="+module_name+"&num_day="+chart_1_num_day, + function(data) { + var temp_data_pie = []; + for(i=0; i 0 && data[0][1] < 7){ // If data is [1:6] day(s) old, put the panel in yellow + $("#day-"+module_name).text(data[0][1] + " Day(s) ago "); + $("#panel-"+module_name).removeClass("panel-green") + $("#panel-"+module_name).addClass("panel-yellow") + } else if (data[0][1] > 6) { // data old of more than 7 days, put the panel in red + $("#day-"+module_name).text(data[0][1] + " Day(s) ago "); + $("#panel-"+module_name).removeClass("panel-green") + $("#panel-"+module_name).addClass("panel-red") + } + } else { + temp_data_pie.push({label: data[i][0], data: data[i][1]}); + tot_sum += data[i][1] + } + } + for(i=0; i + + + - - diff --git a/var/www/templates/trending_graphs/Moduletrending.html b/var/www/templates/trending_graphs/Moduletrending.html index 339676dd..8eaba73b 100644 --- a/var/www/templates/trending_graphs/Moduletrending.html +++ b/var/www/templates/trending_graphs/Moduletrending.html @@ -4,7 +4,7 @@
- Credential - most posted domain + Credential - most posted domain Today
@@ -29,7 +29,7 @@
- Mail - most posted domain (max 1 per paste) + Mail - most posted domain (max 1 per paste) Today
@@ -54,7 +54,7 @@
- Provider + Provider Today