Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/util/colorScale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
createTemporalScale(colorBy, colorings[colorBy].scale, tree.nodes, treeTooNodes));
} else if (scaleType === "continuous") {
({continuous, colorScale, legendBounds, legendValues} =
createContinuousScale(colorBy, colorings[colorBy].scale, tree.nodes, treeTooNodes));
createContinuousScale(colorBy, colorings[colorBy].scale, tree.nodes, treeTooNodes, colorings[colorBy].legend));
} else if (colorings[colorBy].scale) { /* scale set via JSON */
({continuous, legendValues, colorScale} =
createNonContinuousScaleFromProvidedScaleMap(colorBy, colorings[colorBy].scale, tree.nodes, treeTooNodes));
Expand Down Expand Up @@ -262,6 +262,7 @@
providedScale,
t1nodes: ReduxNode[],
t2nodes: ReduxNode[],
userLegend: Legend | undefined
): {
continuous: boolean
colorScale: ColorScale["scale"]
Expand All @@ -270,7 +271,17 @@
} {

const minMax = getMinMaxFromTree(t1nodes, t2nodes, colorBy);


const mmWas = [...minMax];
const userLegendAnchorDomain = userLegend?.map((el) => el?.value);
const userLegendMinMax = [userLegendAnchorDomain?.at(0), userLegendAnchorDomain?.at(-1)];
if (typeof userLegendMinMax[0]==='number' && userLegendMinMax[0] < minMax[0]) minMax[0] = userLegendMinMax[0];
if (typeof userLegendMinMax[1]==='number' && userLegendMinMax[1] > minMax[1]) minMax[1] = userLegendMinMax[1];

console.log("userLegendAnchorDomain", userLegendAnchorDomain || "not present")

Check warning on line 281 in src/util/colorScale.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
if (userLegendAnchorDomain) {
console.log("minMax changed. Was", mmWas, "is now", minMax)

Check warning on line 283 in src/util/colorScale.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
}
/* user-defined anchor points across the scale */
const anchorPoints = _validateAnchorPoints(providedScale, (val) => typeof val==="number");

Expand All @@ -297,6 +308,8 @@
// Hack to avoid a bug: https://github.com/nextstrain/auspice/issues/540
if (Object.is(legendValues[0], -0)) legendValues[0] = 0;

console.log("final domain", domain)

Check warning on line 311 in src/util/colorScale.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement

return {
continuous: true,
colorScale: (val: number) => isValueValid(val) ? scale(val) : unknownColor,
Expand Down
Loading