feat: expose the cached DOM layer compositor #260
main fromtaren/public-layers-current-2043·merged by tannerlinsley Expose the cached DOM compositor at @tanstack/charts/layers so custom SVG layers can reuse it through a focused import. The existing Canvas entry continues to use the same compositor.
The focused layer and Canvas suites passed all 62 tests. Package checks passed and all 146 existing bundle measurements matched main byte for byte. This addresses #204.
Summary by CodeRabbit#
New Features
- Added a public chart-layer composition option for custom renderers, available through the optional layers package entry point.
- Custom SVG layers can share surfaces when adjacent and using the same renderer token, while preserving their authored order. Separate chart instances maintain independent surfaces.
Documentation
- Added guidance and examples for composing custom layers, managing renderer tokens, and understanding layer accessibility and interaction behavior.
- Clarified the available typed and lower-level renderer composition options.
- 1
No actionable comments were generated in the recent review.
Walkthrough
-
The changes add
composeChartLayersas a cached compositor in the@tanstack/charts/layersentry. They expose the lower-level compositor factory, add bundle checks, and update tests, documentation, release notes, and benchmark records.Changes: Chart layer compositor
Layer / File(s) Summary Compositor API and package exports
packages/charts-core/src/canvas.ts,packages/charts-core/src/layers.ts,packages/charts-core/package.json,benchmarks/entries/charts-layers.ts,packages/charts-core/src/layers.test.tsThe package exports composeChartLayersfrom the./layersentry. The compositor caches by default renderer object identity. Tests cover renderer types, SVG layer order and reuse, separate chart hosts, and the absence of Canvas context allocation.Unified bundle verification
scripts/unified-package-artifact.mjsThe unified bundle checks include the layers entry and verify that its bundled output does not contain getContext,ts-chart-canvas, orPath2D.API documentation and release records
.changeset/public-layer-compositor.md,API-FRICTION.md,docs/guides/custom-marks-and-renderers.md,docs/reference/rendering-and-export.md,docs/comparison.md,packages/charts-core/docs/guides/custom-marks-and-renderers.md,packages/charts-core/docs/reference/rendering-and-export.md,packages/charts-core/docs/comparison.md,benchmarks/comparison/bundle-baseline.json,benchmarks/conformance/previews/manifest.jsonThe documentation describes the compositor API, renderer-token surface grouping, per-chart surface ownership, and accessibility and pointer-event behavior. Release and friction records are updated. Comparison revisions and benchmark hashes are refreshed. Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature
Possibly related issues
- TanStack/charts#204 — The changes expose
composeChartLayersfrom@tanstack/charts/layersand add bundle checks for the layers entry, matching the issue’s layer-reuse and bundle objectives.
Suggested reviewers:
greglum - TanStack/charts#204 — The changes expose
Merge Risk:
Minimal · up to18b63-
The new layers entry exposes the compositor without an identified merge-blocking risk. Normal checks remain appropriate before merging.
Pre-merge checks:
4 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Docstring Coverage Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold. Passed checks: 4 passed-
Check name Status Explanation Description Check Check skipped - CodeRabbit’s high-level summary is enabled. Title check The title clearly and concisely describes the main change: exposing the cached DOM layer compositor. Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 5 files. (11 skipped: 11 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
981e6380-4cd7-4b6b-b108-6b1a8da7ba03
Commits-
Reviewing files that changed from the base of the PR and between 3b8922a7744142868f6c7634b91fcedb9caddb01 and 18b63b2590e852ecb5b2ffccb9ce63837494a494.
Files selected for processing: 16-
.changeset/public-layer-compositor.mdAPI-FRICTION.mdbenchmarks/comparison/bundle-baseline.jsonbenchmarks/conformance/previews/manifest.jsonbenchmarks/entries/charts-layers.tsdocs/comparison.mddocs/guides/custom-marks-and-renderers.mddocs/reference/rendering-and-export.mdpackages/charts-core/docs/comparison.mdpackages/charts-core/docs/guides/custom-marks-and-renderers.mdpackages/charts-core/docs/reference/rendering-and-export.mdpackages/charts-core/package.jsonpackages/charts-core/src/canvas.tspackages/charts-core/src/layers.test.tspackages/charts-core/src/layers.tsscripts/unified-package-artifact.mjs
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.
-
-
View your CI Pipeline Execution ↗ for commit 18b63b2590e852ecb5b2ffccb9ce63837494a494
Command Status Duration Result nx run charts-workspace:ci-distributed✅ Succeeded 4m 47s View ↗ nx run charts-workspace:package-check✅ Succeeded 1m 45s View ↗ nx run charts-workspace:benchmark-check✅ Succeeded 47s View ↗
☁️ Nx Cloud last updated this comment at
2026-11-04 20:29:57UTCtannerlinsley merged this9dca5f1
tannerlinsley closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 18b63b2590e852ecb5b2ffccb9ce63837494a494
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR