Skip to content

Fix/318 single trace categorical coloring - #319

Merged
interim17 merged 3 commits into
mainfrom
fix/318-single-trace-categorical-coloring
Nov 12, 2026
Merged

interim17 merged 3 commits into
mainfrom
fix/318-single-trace-categorical-coloring

Conversation

@interim17

@interim17 interim17 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Advances #318

Features with large number of categories were causing memory use to balloon, slowing down performance or crashing.

Solution

Was able to reproduce the issue, asked Claude to review the repo for performance issues related to the problem, and highlighted a few issues.

This PR addresses the fact that using plotly's groupby transform was creating a WebGL trace per transform, which allocated memory for each category on many events.

  • The fix was to use mapCategoriesToColors and directly assign colors to categorical points

Majid tested a preview branch with the changes here and in #322 and it didn't totally solve the problem, but it prevented crashed on the test data set on my local machine, so seems like this is moving in the right direction.

Screenshots (optional):

Screenshot 2026-10-30 at 11 34 38 AM

@github-actions

github-actions Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.6.3
Preview removed because the pull request was closed.
2026-11-12 19:23 UTC

Copilot AI 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.

🟡 Changes recommended

The master checkbox omits the conditional N/A row from its category count, causing an incorrect indeterminate state when rows with missing data are shown or hidden.

1 open issue
What changed in this PR

This PR addresses #318 by reducing memory use and processing overhead when plotting features with thousands of categories.

Changes:

  • Replace Plotly category transforms with a single scatter trace using per-point colors.
  • Use maps and sets for category lookups, and avoid mutating memoized category arrays.
  • Simplify scatter types and hover handling, with regression tests for coloring and category-panel behavior.
File Description
src/​state/​types.ts Unify scatter data under ScatterPlotData.
src/​state/​selection/​selectors.ts Use a set for excluded-category filtering.
src/​state/​plotlyjs-types.ts Remove custom Plotly transform types.
src/​containers/​MainPlotContainer/​test/​selectors.test.ts Test single-trace coloring, overrides, and fallback colors.
src/​containers/​MainPlotContainer/​selectors.ts Replace category transforms with per-point colors.
src/​containers/​MainPlotContainer/​index.tsx Simplify hover handling for prefiltered scatter points.
src/​containers/​ColorByMenu/​test/​selectors.test.ts Test category names, exclusions, and stable N/A rows.
src/​containers/​ColorByMenu/​selectors.ts Optimize category processing and copy arrays before adding N/A.

Review effort: Balanced

Comment thread src/containers/ColorByMenu/selectors.ts Resolved

Copilot AI 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.

🟢 Approval recommended

No active review issues remain for the categorical-coloring changes.

1 open issue

Review effort: Balanced

…o one WebGL trace per category and could not scale to thousands of categories, with a single trace whose marker.color is resolved per point.
@interim17
interim17 force-pushed the fix/318-single-trace-categorical-coloring branch from 384b53c to 3dbb05a Compare November 3, 2026 19:30
@interim17 interim17 mentioned this pull request Nov 3, 2026
@interim17
interim17 marked this pull request as ready for review November 3, 2026 19:45
@interim17
interim17 requested a review from a team as a code owner November 3, 2026 19:45
@interim17
interim17 requested review from ShrimpCryptid and meganrm and a balanced review from Copilot and removed request for a team November 3, 2026 19:45

Copilot AI 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.

🟢 Approval recommended

No active review issues are reported for the change to single-trace, per-point coloring.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@interim17
interim17 requested review from frasercl and removed request for meganrm November 5, 2026 17:11
@interim17
interim17 merged commit 250575d into main Nov 12, 2026
2 checks passed
@interim17
interim17 deleted the fix/318-single-trace-categorical-coloring branch November 12, 2026 19:22
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.

4 participants