Added distribution chart in the package page.
[ppastats.git] / www / js / ppastats.js
index 81d2ef1..9c7e268 100644 (file)
@@ -35,6 +35,58 @@ function ppastats_chart(ddts) {
     });
 }
 
+function ppastats_distros(distros) {
+    var data_chart = [];
+    var max_date = null;
+    var min_date = null;
+    var series_opt = [];
+    
+    $.each(distros, function(i, distro) {
+       var arr = [];
+
+       $.each(distro["ddts"], function(j, item) {
+            var tm = item["time"];
+            var d = new Date(tm[0], tm[1]-1, tm[2]);
+            var entry = [d, item["value"]];
+            arr.push(entry);
+           
+            if (max_date == null || max_date < d) {
+               max_date = d;
+            }
+           
+            if (min_date == null || min_date > d) { 
+               min_date = d;
+            }
+       });
+       data_chart[i] = arr;
+       series_opt[i] = {label: distro["name"]};
+    });
+    
+    var plot1 = $.jqplot ('chart_distro', data_chart, {
+       title: 'Daily Download Count by Ubuntu Distribution',
+        axes: {
+           xaxis: {
+                renderer:$.jqplot.DateAxisRenderer,
+                tickOptions:{formatString:'%Y/%m/%d'},
+                min: min_date,
+                max: max_date
+           },
+           yaxis: {
+                min: 0
+           }
+        },
+        seriesDefaults: {
+           lineWidth:1,
+           showMarker:false
+       },
+       legend: {
+           show: true
+       },
+       series: series_opt
+    });
+}
+
+
 function ppastats_pkg() {
     $(document).ready(function() {
        $("#ppa_owner").html(data["ppa_owner"]);
@@ -54,6 +106,7 @@ function ppastats_pkg() {
 
 
        ppastats_chart(data["ddts"]);
+       ppastats_distros(data["distros"]);
     });
 }