Skip to content

feat: add hexbin transform and Hexgrid mark#542

Draft
RobertFrenken wants to merge 4 commits intosvelteplot:mainfrom
RobertFrenken:feat/hexbin-transform
Draft

feat: add hexbin transform and Hexgrid mark#542
RobertFrenken wants to merge 4 commits intosvelteplot:mainfrom
RobertFrenken:feat/hexbin-transform

Conversation

@RobertFrenken
Copy link
Copy Markdown
Contributor

Summary

  • Adds hexbin transform for binning 2D point data into hexagonal cells with configurable reducers
  • Adds Hexgrid mark for rendering hexagonal grid overlays
  • Supports count, mean, sum, and other reducers via existing reduce infrastructure
  • 8 unit tests for hexbin transform
  • Documentation page with live examples

Closes #86
Closes #80

Split from #531 per reviewer request.

Test plan

  • pnpm test passes
  • pnpm build succeeds
  • pnpm lint passes (prettier formatting fixed)
  • Doc page renders correctly at /transforms/hexbin
  • Visual regression tests

🤖 Generated with Claude Code

Add hexbin transform for aggregating 2D point data into hexagonal bins,
with Hexgrid helper mark and documentation page.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 7, 2026

Deploy Preview for svelteplot ready!

Name Link
🔨 Latest commit f3dfb40
🔍 Latest deploy log https://app.netlify.com/projects/svelteplot/deploys/69d5689cda94270008fa1251
😎 Deploy Preview https://deploy-preview-542--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.

RobertFrenken and others added 2 commits April 6, 2026 21:09
Fixes svelte/no-useless-children-snippet lint error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Cast groupProps to Record<string | symbol, RawValue> for DataRecord
assignment compatibility.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
RobertFrenken added a commit to RobertFrenken/svelteplot that referenced this pull request Apr 7, 2026
…in docs

Add comprehensive unit tests for all 5 Delaunay/Voronoi marks:
- Voronoi (16 tests): rendering, styling, channel mapping, events, edge cases
- VoronoiMesh (11 tests): single-path rendering, attributes, edge cases
- DelaunayMesh (10 tests): triangulation path, attributes, edge cases
- DelaunayLink (12 tests): per-edge paths, styling, events, deduplication
- Hull (14 tests): grouping by z/fill/stroke, styling, edge cases

Fix Hull grouping bug where NaN coordinates during initial reactive render
caused duplicate keyed-each keys crash:
- Guard against NaN with Number.isFinite() instead of typeof === 'number'
- Use index-based each key instead of path string to prevent duplicate keys

Remove hexbin docs (Hexgrid + Hexbin transform sections) that were
incorrectly included in the Delaunay docs page — these belong in the
hexbin PR (svelteplot#542).

## New mark checklist (remaining items for this feature)

- [x] Component source (`src/lib/marks/`)
- [x] Type definitions (`src/lib/types/mark.ts`)
- [x] Exports (`src/lib/marks/index.ts`)
- [x] Sidebar config (`config/sidebar.ts`)
- [x] Docs page (`src/routes/marks/delaunay/+page.md`)
- [x] Unit tests (`src/tests/`)
- [ ] Examples gallery (`src/routes/examples/delaunay/`)
- [ ] Visual regression snapshots (`src/snapshots/delaunay/`)
- [ ] Canvas rendering variants

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
11 tests covering rendering, default/custom styling (stroke, fill,
opacity, strokeWidth), CSS class override, binWidth geometry scaling,
hexagon density, and plot dimension adaptation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gka
Copy link
Copy Markdown
Contributor

gka commented Apr 8, 2026

I see a couple big issues with this:

  • the Hexgrid exceeds the plot area
  • the Hexgrid doesn't line up with the hexbin positions
  • the examples are not very meaningful

For reference, here's how the grid lines up in ObservablePlot

image

@gka gka marked this pull request as draft April 8, 2026 14:05
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.

feature: add hexgrid mark feature: add hexbin transform

2 participants