From 7ad77789659bde822e3b6f3d2f7edb433cacf3ac Mon Sep 17 00:00:00 2001 From: David Kaltschmidt Date: Fri, 20 Nov 2015 13:00:41 +0100 Subject: [PATCH] Skip green and red colors for nodes --- client/app/scripts/mixins/node-color-mixin.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/client/app/scripts/mixins/node-color-mixin.js b/client/app/scripts/mixins/node-color-mixin.js index 845d832b4..525005d88 100644 --- a/client/app/scripts/mixins/node-color-mixin.js +++ b/client/app/scripts/mixins/node-color-mixin.js @@ -1,17 +1,24 @@ const d3 = require('d3'); const colors = d3.scale.category20(); - -// make sure the internet always gets the same color -const internetLabel = 'the Internet'; -colors(internetLabel); - +const PSEUDO_COLOR = '#b1b1cb'; +let colorIndex = 0; const NodeColorMixin = { getNodeColor: function(text) { + colorIndex++; + // skip green and red (index 5-8 in d3.scale.category20) + if (colorIndex > 4 && colorIndex < 9) { + colors('_' + colorIndex); + return this.getNodeColor(text); + } + return colors(text); }, getNodeColorDark: function(text) { + if (text === undefined) { + return PSEUDO_COLOR; + } const color = d3.rgb(colors(text)); let hsl = color.hsl();