]> git.donarmstrong.com Git - neurodebian.git/commitdiff
1st version of 'coloring' subscription chart
authorYaroslav Halchenko <debian@onerussian.com>
Tue, 21 May 2013 14:09:36 +0000 (10:09 -0400)
committerYaroslav Halchenko <debian@onerussian.com>
Tue, 21 May 2013 14:09:36 +0000 (10:09 -0400)
sphinx/_static/subscriptionchart.js

index 5320f0a86ba50284be8002b1840c6aa671f177e9..37b98a26e83b498b5c97ab32c3a830d460e31358 100644 (file)
@@ -1,11 +1,39 @@
 d3.json('/_files/nd_subscriptionstats.json', function(data) {
+
+  // collect debian and ubuntu releases we are dealing with to create
+  // proper color scales
+  var debian_releases = new Array()
+  var ubuntu_releases = new Array()
+
+       data.forEach(function(d, i) {
+       if (d.key.indexOf("Ubuntu") > -1)
+          ubuntu_releases.push(d.key)
+      else
+          debian_releases.push(d.key);
+  })
+
+  // yoh: can't find a sane way to use ordinal scale here
+  // so let's create linear scale for indices within known releases
+  var colors_debian = d3.scale.linear()
+       .domain([0, debian_releases.length]).range(["white", "#dd1155"])
+  var colors_ubuntu = d3.scale.linear()
+       .domain([0, ubuntu_releases.length]).range(["white", "#dd4814"])
+
+  releaseKeyColor = function(d, i) {
+       if (d.key.indexOf("Ubuntu") > -1)
+               return colors_ubuntu(ubuntu_releases.indexOf(d.key)+1)
+       else
+               return colors_debian(debian_releases.indexOf(d.key)+1);
+  }
+
   nv.addGraph(function() {
     chart = nv.models.stackedAreaChart()
                   .x(function(d) { return d[0] })
                   .y(function(d) { return d[1] })
+                  .color(releaseKeyColor)
                   .clipEdge(true);
 
-    chart.stacked.style('expand');
+    chart.stacked.style('stacked');
 
     chart.xAxis
         .tickFormat(function(d) {