diff --git a/src/ui/views/map/ColorLegend.js b/src/ui/views/map/ColorLegend.js index c4606b45..085f103e 100644 --- a/src/ui/views/map/ColorLegend.js +++ b/src/ui/views/map/ColorLegend.js @@ -133,7 +133,7 @@ const NumericalColorLegend = ({ ? `[${getFormattedValue(index - 1)}, ${getFormattedValue(index)}) "${getLabel(index)}"` : `"${getLabel(index)}"` : isStepScale - ? `${index < 1 ? `(-\u221E, ${getFormattedValue(index)})` : `[${getFormattedValue(index)}, \u221E)`}` + ? `${index < 1 ? `(-\u221E, ${getFormattedValue(index)})` : `[${getFormattedValue(index - 1)}, \u221E)`}` : `${index < 1 ? 'Min' : 'Max'}`, [getFormattedValue, getLabel, isStepScale, values] ) @@ -226,16 +226,15 @@ const NumericalColorLegend = ({ {showColorPickers && (values.length < 3 ? ( - // BUG: For some reason the `sx` prop doesn't work here { throw new Error(`Invalid scale "${scale}"`) } - const scaleFunc = scaleBuilder - .domain(domain) - .range(range) - .unknown(fallback) - ?.clamp(true) // Clamp whenever the scaling function supports it - return scaleFunc(value) // Return the scaled value or the fallback + const scaleFunc = scaleBuilder.domain(domain).range(range).unknown(fallback) + // Return the scaled value or the fallback + return scale === scaleId.STEP + ? scaleFunc(value) + : // Clamp for all scales except the step function + scaleFunc.clamp(true)(value) } )