Skip to content

fix: color stability, null facet support, and tooltip event leak#508

Merged
gka merged 4 commits into
mainfrom
fix/color-stability-null-facets-tooltip-leak
Mar 8, 2026
Merged

fix: color stability, null facet support, and tooltip event leak#508
gka merged 4 commits into
mainfrom
fix/color-stability-null-facets-tooltip-leak

Conversation

@ljodea

@ljodea ljodea commented Feb 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Color stability: Pin color.domain and fx.domain in the faceted bars example so unchecking a party checkbox no longer reshuffles remaining bars' colors
  • Null facet support ([BUG]: Faceting drops entries with null values #99): Allow null values in fx/fy scale domains — null is a valid grouping category (e.g. penguins with sex = null). Also exempt fx/fy from the data validity check so null-faceted records render.
  • Tooltip event leak: Fix removeEventListener('mouseleave', ...)removeEventListener('pointerleave', ...) in HTMLTooltip to match the corresponding addEventListener

Changes

File Change
src/routes/examples/bar/faceted-bars.svelte Pin color.domain and fx.domain to [...parties]
src/lib/helpers/scales.ts Allow null in fx/fy domain filter
src/lib/Mark.svelte Exempt fx/fy from isValid check (null facet values are valid)
src/lib/marks/HTMLTooltip.svelte Fix mouseleavepointerleave
src/tests/colorStability.test.svelte.ts New: 3 tests for color stability with explicit domain
src/tests/nullFacet.test.svelte.ts New: 1 test for null fx facet rendering
src/lib/helpers/facets.test.ts Extend: 2 tests for null fx/fy in getEmptyFacets

Test plan

  • pnpm test — 683 tests pass (85 files)
  • pnpm check — 0 errors
  • pnpm lint — clean
  • Manual: open faceted bars example, uncheck a party → remaining bars keep their colors, unchecked facet disappears
  • Manual: render data with null facet values → null column appears with data

🤖 Generated with Claude Code

Pin color.domain and fx.domain in faceted bars example so unchecking
a party checkbox no longer reshuffles remaining bars' colors.

Allow null values in fx/fy scale domains (#99) — null is a valid
grouping category for facet scales. Also exempt fx/fy from the
data validity check in Mark.svelte so null-faceted records render.

Fix HTMLTooltip event listener mismatch: removeEventListener was
using 'mouseleave' instead of 'pointerleave', causing a leak.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@netlify

netlify Bot commented Feb 28, 2026

Copy link
Copy Markdown

Deploy Preview for svelteplot ready!

Name Link
🔨 Latest commit 9b267da
🔍 Latest deploy log https://app.netlify.com/projects/svelteplot/deploys/69ad2534f0fca60008ef7683
😎 Deploy Preview https://deploy-preview-508--svelteplot.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@gka gka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Makes sense to change the faceted-bars example to pin the colors, but I don't think the "empty" facets should show up on the x axis. That's something users would likely never want in a real-world scenario

image

A more practical way to pin the colors is to pass a dictionary as color scheme

gka and others added 3 commits March 4, 2026 14:19
Use a scheme dictionary mapping party names to recognizable colors
instead of relying on domain + default categorical colors.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
…chemes

The runtime already supports dictionary objects as color schemes
(autoScales.ts:246) but the type definition didn't include them.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@ljodea

ljodea commented Mar 8, 2026

Copy link
Copy Markdown
Collaborator Author

Done. Please check @gka
image

@ljodea ljodea requested a review from gka March 8, 2026 08:37
@gka

gka commented Mar 8, 2026

Copy link
Copy Markdown
Contributor

perfect

@gka gka merged commit 6425b47 into main Mar 8, 2026
8 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