From: Lunar <lunar@anargeek.net>
Date: Sun, 17 Nov 2013 21:37:30 +0000 (+0100)
Subject: Services : on cache les morceaux de courbes pour lesquels on a pas toutes les donnĂ©es
X-Git-Url: https://nos-oignons.net/gitweb/website.git/commitdiff_plain/5e5ec4cf05ebd15a7d1e9f2cf0d5f3cfa1a156d1?ds=sidebyside;hp=6ba22ed07ee3e37bce41c9a7c814d105b2621d70

Services : on cache les morceaux de courbes pour lesquels on a pas toutes les donnĂ©es
---

diff --git a/Services/Participation.html b/Services/Participation.html
index 4683683..56ae6db 100644
--- a/Services/Participation.html
+++ b/Services/Participation.html
@@ -214,8 +214,8 @@ function draw_bandwidth_graph(raw_data, selector, direction, period) {
   });
   color.domain(valid_fingerprints);
 
-  var minTime = d3.min(raw_data.relays.map(function(d) { return d[direction][period] && parseTime(d[direction][period].first); }));
-  var maxTime = d3.max(raw_data.relays.map(function(d) { return d[direction][period] && parseTime(d[direction][period].last); }));
+  var minTime = d3.max(raw_data.relays.map(function(d) { return d[direction][period] && parseTime(d[direction][period].first); }));
+  var maxTime = d3.min(raw_data.relays.map(function(d) { return d[direction][period] && parseTime(d[direction][period].last); }));
   var maxTotalBandwidth = 0;
 
   var data = stack(color.domain().map(function(fingerprint) {
@@ -227,13 +227,9 @@ function draw_bandwidth_graph(raw_data, selector, direction, period) {
     var last = parseTime(history.last);
     var i = 0;
     for (var current = minTime; current <= maxTime; current = d3.time.second.offset(current, history.interval)) {
-      var value;
-      if (current < first || current > last) {
-        value = 0;
-      } else {
-        value = history.factor * history.values[i++];
+      if (first <= current && current <= last) {
+        values.push({ date: current, y: history.factor * history.values[i++] });
       }
-      values.push({ date: current, y: value });
     }
 
     maxTotalBandwidth = maxTotalBandwidth + history.factor * d3.max(history.values);