Skip to content

feat: canvas rendering for Rect, Cell and Bar marks#333

Merged
gka merged 3 commits intomainfrom
feat/rect-canvas
Jan 19, 2026
Merged

feat: canvas rendering for Rect, Cell and Bar marks#333
gka merged 3 commits intomainfrom
feat/rect-canvas

Conversation

@gka
Copy link
Contributor

@gka gka commented Jan 18, 2026

resolves #24, #27 and #29

This pull request adds support for rendering bar, cell, and rect marks using Canvas in addition to SVG, which can improve performance for large datasets. The main changes introduce a new canvas prop to the relevant mark components and implement a shared helper component, RectCanvas.svelte, for efficient Canvas rendering.

Canvas rendering support

  • Added a canvas boolean prop to BarX.svelte, BarY.svelte, Cell.svelte, and Rect.svelte to allow users to choose Canvas rendering instead of SVG. [1] [2] [3] [4]
  • Updated mark components to conditionally render using the new RectCanvas.svelte helper when canvas is true, including appropriate data transformations for Canvas drawing. [1] [2] [3] [4]

New shared Canvas helper

  • Implemented src/lib/marks/helpers/RectCanvas.svelte, a reusable helper for drawing rectangles (bars, cells, etc.) on a Canvas, supporting style, border radius, and insets.
  • Imported RectCanvas.svelte into the relevant mark components to enable Canvas rendering. [1] [2] [3] [4]

Component API consistency

  • Standardized the class prop naming in Rect.svelte for consistency with other components. [1] [2]

These changes provide a significant performance and flexibility improvement for rendering visualizations, especially with larger datasets.

@github-actions
Copy link

📦 Preview package for this PR is published!

Version: 0.9.1-pr-333.0

Install it with:

npm install svelteplot@pr-333
# or install the specific version
npm install svelteplot@0.9.1-pr-333.0

@github-actions
Copy link

TypeScript error report:

  • This branch: 859
  • main branch: 1114
  • Difference (PR - main): -255 🎉

Svelte TypeScript error report:

  • This branch: 2136
  • main branch: 2112
  • Difference (PR - main): +24 ⚠️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds Canvas rendering support as an alternative to SVG for Rect, Cell, BarX, and BarY marks, which can significantly improve performance for large datasets. The changes introduce a new canvas boolean prop to these mark components and implement a shared RectCanvas.svelte helper component for efficient Canvas rendering.

Changes:

  • Added a new reusable RectCanvas.svelte helper component for Canvas-based rectangle rendering with support for insets, border radius, and styling
  • Updated Rect, Cell, BarX, and BarY mark components to support optional Canvas rendering via a new canvas prop
  • Standardized the class prop naming in Rect.svelte (changed from className to class)

Reviewed changes

Copilot reviewed 6 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/lib/marks/helpers/RectCanvas.svelte New shared helper component for rendering rectangles on Canvas with full style and inset support
src/lib/marks/Rect.svelte Added canvas prop and conditional rendering logic; standardized class prop naming
src/lib/marks/Cell.svelte Added canvas prop with data transformation for Canvas rendering
src/lib/marks/BarX.svelte Added canvas prop with bandwidth calculation and data mapping
src/lib/marks/BarY.svelte Added canvas prop with bandwidth calculation and data mapping
src/routes/examples/cell/cell-canvas.svelte New example demonstrating Canvas rendering with Cell mark
src/routes/transforms/bin/+page.md Updated example to use Canvas rendering
src/snapshots/cell/cell-canvas.png New snapshot file for Canvas Cell example (light theme)
src/snapshots/cell/cell-canvas.dark.png New snapshot file for Canvas Cell example (dark theme)

@netlify
Copy link

netlify bot commented Jan 18, 2026

Deploy Preview for svelteplot ready!

Name Link
🔨 Latest commit 0a7db5b
🔍 Latest deploy log https://app.netlify.com/projects/svelteplot/deploys/696d6aa7fc147f00086c7910
😎 Deploy Preview https://deploy-preview-333--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.

@github-actions
Copy link

TypeScript error report:

  • This branch: 859
  • main branch: 1114
  • Difference (PR - main): -255 🎉

Svelte TypeScript error report:

  • This branch: 2136
  • main branch: 2112
  • Difference (PR - main): +24 ⚠️

@github-actions
Copy link

📦 Preview package for this PR is published!

Version: 0.9.1-pr-333.1

Install it with:

npm install svelteplot@pr-333
# or install the specific version
npm install svelteplot@0.9.1-pr-333.1

@github-actions
Copy link

📦 Preview package for this PR is published!

Version: 0.9.1-pr-333.2

Install it with:

npm install svelteplot@pr-333
# or install the specific version
npm install svelteplot@0.9.1-pr-333.2

@github-actions
Copy link

TypeScript error report:

  • This branch: 855
  • main branch: 1115
  • Difference (PR - main): -260 🎉

Svelte TypeScript error report:

  • This branch: 2137
  • main branch: 2113
  • Difference (PR - main): +24 ⚠️

@gka gka merged commit 0e922c4 into main Jan 19, 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.

Canvas rendering for Cell mark

1 participant