From da17bd502c2c951bc20c2b218c8c08643c79d1cd Mon Sep 17 00:00:00 2001 From: John Huddleston Date: Thu, 29 Aug 2024 10:55:47 -0700 Subject: [PATCH] Remove custom LBI color scale Closes #805 --- CHANGELOG.md | 1 + src/util/colorScale.js | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3304bdce5..5f2685980 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # Changelog +* Remove hardcoded color scale for LBI ([#1842](https://github.com/nextstrain/auspice/pull/1842)) * Any `node_attr` in the tree can be used as a tip label, as well as the special-cases of strain-name and "none". Previously we only allowed valid colorings. ([#1668](https://github.com/nextstrain/auspice/pull/1668)) diff --git a/src/util/colorScale.js b/src/util/colorScale.js index 14a78e8eb..8b05c3abe 100644 --- a/src/util/colorScale.js +++ b/src/util/colorScale.js @@ -223,12 +223,7 @@ function createOrdinalScale(colorBy, t1nodes, t2nodes) { function createContinuousScale(colorBy, providedScale, t1nodes, t2nodes) { - let minMax; - if (colorBy==="lbi") { - minMax = [0, 0.7]; /* TODO: this is for historical reasons, and we should switch to a provided scale */ - } else { - minMax = getMinMaxFromTree(t1nodes, t2nodes, colorBy); - } + let minMax = getMinMaxFromTree(t1nodes, t2nodes, colorBy); /* user-defined anchor points across the scale */ const anchorPoints = _validateAnchorPoints(providedScale, (val) => typeof val==="number"); @@ -245,18 +240,14 @@ function createContinuousScale(colorBy, providedScale, t1nodes, t2nodes) { const scale = scaleLinear().domain(domain).range(range); let legendValues; - if (colorBy==="lbi") { - /* TODO: this is for historical reasons, and we should switch to a provided scale */ - legendValues = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7]; - } else { - const spread = minMax[1] - minMax[0]; - const dp = spread > 5 ? 2 : 3; - /* if legend values are identical (for the specified number of decimal places) then we - should filter them out */ - legendValues = genericDomain - .map((d) => parseFloat((minMax[0] + d*spread).toFixed(dp))) - .filter((el, idx, values) => values.indexOf(el)===idx); - } + const spread = minMax[1] - minMax[0]; + const dp = spread > 5 ? 2 : 3; + /* if legend values are identical (for the specified number of decimal places) then we + should filter them out */ + legendValues = genericDomain + .map((d) => parseFloat((minMax[0] + d*spread).toFixed(dp))) + .filter((el, idx, values) => values.indexOf(el)===idx); + // Hack to avoid a bug: https://github.com/nextstrain/auspice/issues/540 if (Object.is(legendValues[0], -0)) legendValues[0] = 0;