Skip to content

Fix point size scaling when filtering to single value#357

Merged
ethanbienstock merged 2 commits into
raft-tech:mainfrom
lhawkman27:355-fix-point-size-scaling-when-filtering-in-dashboard
Apr 25, 2026
Merged

Fix point size scaling when filtering to single value#357
ethanbienstock merged 2 commits into
raft-tech:mainfrom
lhawkman27:355-fix-point-size-scaling-when-filtering-in-dashboard

Conversation

@lhawkman27
Copy link
Copy Markdown
Collaborator

@lhawkman27 lhawkman27 commented Apr 1, 2026

Summary

  • Fix computeSizeScale to return midpoint size instead of minimum when all data points share the same value (range === 0)
  • Detect noSizeRange in transformProps and collapse legend to a static swatch with accurate singleValueColor
  • Add single-value fallback rendering in both Legend and MultiLegend components
  • Tighten singleValueColor type from number[] to RGBAColor, extract shared helpers, and add comprehensive test coverage

Focus 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.tscomputeSizeScale: when range === 0, return Math.round((startSize + endSize) / 2) instead of startSize. Null/NaN guard still returns startSize.
  • src/transformProps.ts — Detect noSizeRange by comparing sortedValues[0] to sortedValues[last]. Collapse legend startSize/endSize to the midpoint when true. Compute singleValueColor via metricColorScale so the legend swatch matches the rendered point color. Add legendName to SizeLegend for fallback display.
  • src/components/Legend.tsx — Change singleValueColor type from number[] to RGBAColor on SizeLegend. Extract renderSingleValueRow helper. Use it for both standalone size legend and combined metric+size single-value fallback. Remove all as RGBAColor casts.
  • src/components/MultiLegend.tsx — Extract singleValueSizeRow variable to deduplicate two identical 10-line JSX blocks. Remove as RGBAColor casts. 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 — Update computeSizeScale tests for midpoint behavior when range is 0.
  • test/utils/percentileBounds.test.ts — Update expected size values to reflect midpoint instead of startSize.

Test Plan

  • Run full plugin test suite: npx jest --no-coverage plugins/geoset-map-chart/test/ — all 590 tests should pass
  • In a dashboard with a map chart using dynamic point sizing, apply a filter that reduces to a single data point — verify the point renders at a visible mid-range size (should hold it's shape)
  • Verify the legend shows a static swatch with correct color instead of empty/graduated icons
  • Remove the filter to restore multiple points — verify graduated icons and normal size scaling return
  • Test with combined metric+size coloring (same column for color and size) — verify swatch color matches the point
  • Test with separate metric and size columns — verify legend renders correctly

🤖 Generated with Claude Code

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>
@lhawkman27 lhawkman27 changed the title Fix point size scaling when filtering to single value in dashboard (#355) Fix point size scaling when filtering to single value in dashboard Apr 1, 2026
@lhawkman27 lhawkman27 changed the title Fix point size scaling when filtering to single value in dashboard Fix point size scaling when filtering to single value Apr 1, 2026
@lhawkman27 lhawkman27 self-assigned this Apr 1, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@ethanbienstock ethanbienstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ethanbienstock ethanbienstock merged commit e4d9b88 into raft-tech:main Apr 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants