From 90dd85da7b9870c293cb37aefabebf54de6d09b3 Mon Sep 17 00:00:00 2001 From: Ivan Mikheykin Date: Mon, 3 Sep 2018 16:50:26 +0300 Subject: [PATCH] fix null not mapped error --- src/color_mode_discrete.js | 14 ++++++++++++++ src/rendering.js | 30 ------------------------------ 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/color_mode_discrete.js b/src/color_mode_discrete.js index aae392a..5b6372d 100644 --- a/src/color_mode_discrete.js +++ b/src/color_mode_discrete.js @@ -65,6 +65,20 @@ export class ColorModeDiscrete { } getMatchedThreshold(value) { + if (value == null) { + if (this.panel.color.nullPointMode == 'as empty') { + // FIXME: make this explicit for user + // Right now this color never used because null as empty handles in getCardOpacity method. + return { + "color": "rgba(0,0,0,0)", + "value": "null", + "tooltip": "null", + } + } else { + value = 0; + } + } + let thresholds = this.panel.color.thresholds; for (let k = 0; k < thresholds.length; k++) { if (value == thresholds[k].value) { diff --git a/src/rendering.js b/src/rendering.js index 97180e2..1b7403b 100644 --- a/src/rendering.js +++ b/src/rendering.js @@ -333,36 +333,6 @@ export default function link(scope, elem, attrs, ctrl) { return d3.scaleSequential(colorInterpolator).domain([start, end]); } -// scale input range to discrete colors to draw a legend - function getDiscreteColorScale() { - let thresholds = panel.color.thresholds; - - let thresholdValues = []; - let thresholdColors = []; - for (let i = 0; i < thresholds.length; i++) { - thresholdColors.push(thresholds[i].color); - thresholdValues.push(thresholds[i].value); - } - - // TODO sort colors by value and index? - - let thresholdScaler = (d) => { - for (let i = 0; i < thresholdValues.length; i++ ) { - if (d == thresholdValues[i]) { - return thresholdColors[i]; - } - } - // Error if value not in thresholds - return 'rgba(0,0,0,1)'; - }; - - // scale min-max to 0 - max-thrs-value - return function(d) { - return thresholdScaler(d); - } - } - - function setOpacityScale(maxValue) { if (panel.color.colorScale === 'linear') { opacityScale = d3.scaleLinear()