Fix point size scaling when filtering to single value#357
Merged
ethanbienstock merged 2 commits intoApr 25, 2026
Merged
Conversation
When dashboard filters reduce data to a single point (or all points sharing the same size value), computeSizeScale now returns the midpoint of startSize/endSize instead of the minimum. The legend collapses to a static swatch instead of empty graduated icons, with singleValueColor ensuring the swatch matches the actual rendered point color. Also tightens singleValueColor type from number[] to RGBAColor, extracts shared helpers for single-value swatch rendering, and adds test coverage for all single-value legend paths in both Legend and MultiLegend. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
computeSizeScaleto return midpoint size instead of minimum when all data points share the same value (range === 0)noSizeRangeintransformPropsand collapse legend to a static swatch with accuratesingleValueColorLegendandMultiLegendcomponentssingleValueColortype fromnumber[]toRGBAColor, extract shared helpers, and add comprehensive test coverageFocus Score
9/10 — All changes are tightly focused on the single bug: point size scaling when filtering reduces data to one unique value. The type tightening and helper extraction are direct refinements to the same code paths.
Detailed Summary of Each File Changed
src/utils/colors.ts—computeSizeScale: whenrange === 0, returnMath.round((startSize + endSize) / 2)instead ofstartSize. Null/NaN guard still returnsstartSize.src/transformProps.ts— DetectnoSizeRangeby comparingsortedValues[0]tosortedValues[last]. Collapse legendstartSize/endSizeto the midpoint when true. ComputesingleValueColorviametricColorScaleso the legend swatch matches the rendered point color. AddlegendNametoSizeLegendfor fallback display.src/components/Legend.tsx— ChangesingleValueColortype fromnumber[]toRGBAColoronSizeLegend. ExtractrenderSingleValueRowhelper. Use it for both standalone size legend and combined metric+size single-value fallback. Remove allas RGBAColorcasts.src/components/MultiLegend.tsx— ExtractsingleValueSizeRowvariable to deduplicate two identical 10-line JSX blocks. Removeas RGBAColorcasts. Used in both combined metric+size and standalone size legend branches.test/components/Legend.test.tsx— Add 3 tests: singleValueColor swatch rendering, fillColor fallback, combined metric+size single-value fallback.test/components/MultiLegend.test.tsx— Add GraduatedIcons/CategorySizeGrid mocks and 5 tests: simple entry with collapsed size, combined metric+size swatch, standalone size swatch, singleValueColor usage, graduated icons positive control.test/utils/colors.test.ts— UpdatecomputeSizeScaletests for midpoint behavior when range is 0.test/utils/percentileBounds.test.ts— Update expected size values to reflect midpoint instead of startSize.Test Plan
npx jest --no-coverage plugins/geoset-map-chart/test/— all 590 tests should pass🤖 Generated with Claude Code