Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Changed map radiusScale for increased size for small values #1945

Merged
merged 3 commits into from
Jan 8, 2025
Merged
Changes from 1 commit
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
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) {
bprusinowski marked this conversation as resolved.
Show resolved Hide resolved
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
Loading