Skip to content

Commit

Permalink
fix: Changed map radiusScale to not show 0 values but increase size o…
Browse files Browse the repository at this point in the history
…f smaller values
  • Loading branch information
noahonyejese committed Jan 7, 2025
1 parent fe17af3 commit df7e99f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions app/charts/map/map-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,24 @@ const useMapState = (
});

const radiusScale = useMemo(() => {
// Measure dimension is undefined. Can be useful when the user wants to
// encode only the color of symbols, and the size is irrelevant.
if (symbolLayerState.dataDomain[1] === undefined) {
return scaleSqrt().range([0, 12]).unknown(12);
} else {
return scaleSqrt()
.domain([0, symbolLayerState.dataDomain[1]])
.range([0, 24]);
}

const baseScale = scaleSqrt()
.domain([0, symbolLayerState.dataDomain[1]])
.range([0, 24]);

const wrappedScale = (x: number | null) => {
if (x === null || x === undefined) return 0;
if (x === 0) return 0;
const scaled = baseScale(x);
return Math.max(2, scaled);
};

Object.assign(wrappedScale, baseScale);

return wrappedScale;
}, [symbolLayerState.dataDomain]) as ScalePower<number, number>;

const preparedSymbolLayerState: MapState["symbolLayer"] = useMemo(() => {
Expand Down

0 comments on commit df7e99f

Please sign in to comment.