From: Sebastien Duthil Date: Sat, 8 Aug 2015 01:48:16 +0000 (-0400) Subject: Couleurs du graphe de trafic X-Git-Url: https://nos-oignons.net/gitweb/website.git/commitdiff_plain/77db51cc59b6507ffbd5ab4e4dffe4d440eb9a1d?ds=sidebyside Couleurs du graphe de trafic --- diff --git a/assets/bw_graphs.js b/assets/bw_graphs.js index b6147b6..bed5e11 100644 --- a/assets/bw_graphs.js +++ b/assets/bw_graphs.js @@ -16,8 +16,6 @@ BwDrawer.x = d3.time.scale() BwDrawer.y = d3.scale.linear() .range([BwDrawer.height, 0]); -BwDrawer.color = d3.scale.category20(); - BwDrawer.xAxis = d3.svg.axis() .scale(BwDrawer.x) .orient("bottom"); @@ -58,6 +56,10 @@ BwDrawer.extract_values = function(history, interval, minTime, maxTime) { 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; @@ -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) { diff --git a/assets/relays.js b/assets/relays.js index f564c83..a3c6500 100644 --- a/assets/relays.js +++ b/assets/relays.js @@ -1,13 +1,19 @@ +// Colors from https://github.com/mbostock/d3/wiki/Ordinal-Scales#category20 var nos_oignons_relays = [ { name: "marcuse1", fingerprint: "EFAE44728264982224445E96214C15F9075DEE1D", + color: "#1f77b4", }, { name: "marcuse2", fingerprint: "C656B41AEFB40A141967EBF49D6E69603C9B4A11", + color: "#aec7e8", }, { name: "ekumen", fingerprint: "9BA84E8C90083676F86C7427C8D105925F13716C", + color: "#ff7f0e", }, { name: "marylou1", fingerprint: "578E007E5E4535FBFEF7758D8587B07B4C8C5D06", + color: "#2ca02c", }, { name: "marylou2", fingerprint: "90FD830C357A5109AB3C505287713F1AC811174C", + color: "#98df8a", }, - ]; +];