]> nos-oignons.net Git - website.git/commitdiff
Couleurs du graphe de trafic
authorSebastien Duthil <duthils@free.fr>
Sat, 8 Aug 2015 01:48:16 +0000 (21:48 -0400)
committerLunar <lunar@anargeek.net>
Sat, 8 Aug 2015 09:41:16 +0000 (11:41 +0200)
assets/bw_graphs.js
assets/relays.js

index b6147b6d0d16a624a62e4915e7577f8ecf80c062..bed5e11d56106da427e252b8bec077fa83609a6a 100644 (file)
@@ -16,8 +16,6 @@ BwDrawer.x = d3.time.scale()
 BwDrawer.y = d3.scale.linear()
     .range([BwDrawer.height, 0]);
 
 BwDrawer.y = d3.scale.linear()
     .range([BwDrawer.height, 0]);
 
-BwDrawer.color = d3.scale.category20();
-
 BwDrawer.xAxis = d3.svg.axis()
     .scale(BwDrawer.x)
     .orient("bottom");
 BwDrawer.xAxis = d3.svg.axis()
     .scale(BwDrawer.x)
     .orient("bottom");
@@ -58,6 +56,10 @@ BwDrawer.extract_values = function(history, interval, minTime, maxTime) {
   return values;
 }
 
   return values;
 }
 
+BwDrawer.color = d3.scale.ordinal();
+BwDrawer.color.domain(nos_oignons_relays.map(function(r) {return r.fingerprint}));
+BwDrawer.color.range(nos_oignons_relays.map(function(r) {return r.color}));
+
 BwDrawer.draw_bandwidth_graph = function(raw_data, selector, period) {
   var update_period;
 
 BwDrawer.draw_bandwidth_graph = function(raw_data, selector, period) {
   var update_period;
 
@@ -84,13 +86,6 @@ BwDrawer.draw_bandwidth_graph = function(raw_data, selector, period) {
     }
   });
 
     }
   });
 
-  var valid_fingerprints = [];
-  nos_oignons_relays.forEach(function(r) {
-    var relay_data = raw_data["relays"].filter(function(d) { return d.fingerprint == r.fingerprint; })[0];
-    valid_fingerprints.push(r.fingerprint);
-  });
-  BwDrawer.color.domain(valid_fingerprints);
-
   var bw_data = {};
   BwDrawer.periods.map(function(p) { return p.id; }).forEach(function(period) {
     var interval = d3.max(raw_data.relays, function(d) {
   var bw_data = {};
   BwDrawer.periods.map(function(p) { return p.id; }).forEach(function(period) {
     var interval = d3.max(raw_data.relays, function(d) {
index f564c837d23816609f510d2ff886774920b0ba43..a3c6500ea0765e04f28eb61b61180f272ba0d873 100644 (file)
@@ -1,13 +1,19 @@
+// Colors from https://github.com/mbostock/d3/wiki/Ordinal-Scales#category20
 var nos_oignons_relays = [
        { name: "marcuse1",
          fingerprint: "EFAE44728264982224445E96214C15F9075DEE1D",
 var nos_oignons_relays = [
        { name: "marcuse1",
          fingerprint: "EFAE44728264982224445E96214C15F9075DEE1D",
+         color: "#1f77b4",
     }, { name: "marcuse2",
          fingerprint: "C656B41AEFB40A141967EBF49D6E69603C9B4A11",
     }, { name: "marcuse2",
          fingerprint: "C656B41AEFB40A141967EBF49D6E69603C9B4A11",
+         color: "#aec7e8",
     }, { name: "ekumen",
          fingerprint: "9BA84E8C90083676F86C7427C8D105925F13716C",
     }, { name: "ekumen",
          fingerprint: "9BA84E8C90083676F86C7427C8D105925F13716C",
+         color: "#ff7f0e",
     }, { name: "marylou1",
          fingerprint: "578E007E5E4535FBFEF7758D8587B07B4C8C5D06",
     }, { name: "marylou1",
          fingerprint: "578E007E5E4535FBFEF7758D8587B07B4C8C5D06",
+         color: "#2ca02c",
     }, { name: "marylou2",
          fingerprint: "90FD830C357A5109AB3C505287713F1AC811174C",
     }, { name: "marylou2",
          fingerprint: "90FD830C357A5109AB3C505287713F1AC811174C",
+         color: "#98df8a",
     },
     },
-  ];
+];