Skip to content
Source
Sign inSign up
TanStack/charts

feat: expose the cached DOM layer compositor #260

Mergedtannerlinsleymerged 2 commits intomain fromtaren/public-layers-current-2043merged by tannerlinsley

tannerlinsleycommented

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. 🦋 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
      NameType
      @tanstack/chartsMinor
      @tanstack/alpine-chartsMinor
      @tanstack/angular-chartsMinor
      @tanstack/lit-chartsMinor
      @tanstack/octane-chartsMinor
      @tanstack/preact-chartsMinor
      @tanstack/react-chartsMinor
      @tanstack/react-native-chartsMinor
      @tanstack/solid-chartsMinor
      @tanstack/svelte-chartsMinor
      @tanstack/vue-chartsMinor
      @tanstack/charts-scalesMinor

      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

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      The changes add composeChartLayers as a cached compositor in the @tanstack/charts/layers entry. 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.ts
      The package exports composeChartLayers from the ./layers entry. 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.mjs
      The unified bundle checks include the layers entry and verify that its bundled output does not contain getContext, ts-chart-canvas, or Path2D.
      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.json
      The 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 composeChartLayers from @tanstack/charts/layers and add bundle checks for the layers entry, matching the issue’s layer-reuse and bundle objectives.

      Suggested reviewers: greglum

      Merge Risk: Minimal · up to 18b63

      The new layers entry exposes the compositor without an identified merge-blocking risk. Normal checks remain appropriate before merging.

      Pre-merge checks: Passed 4 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Docstring CoverageWarningDocstring 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 Passed checks: 4 passed
      Check nameStatusExplanation
      Description CheckPassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title checkPassedThe title clearly and concisely describes the main change: exposing the cached DOM layer compositor.
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck 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.

      Share
      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.md
      • API-FRICTION.md
      • benchmarks/comparison/bundle-baseline.json
      • benchmarks/conformance/previews/manifest.json
      • benchmarks/entries/charts-layers.ts
      • docs/comparison.md
      • docs/guides/custom-marks-and-renderers.md
      • docs/reference/rendering-and-export.md
      • packages/charts-core/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/package.json
      • packages/charts-core/src/canvas.ts
      • packages/charts-core/src/layers.test.ts
      • packages/charts-core/src/layers.ts
      • scripts/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.

    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 18b63b2590e852ecb5b2ffccb9ce63837494a494

      CommandStatusDurationResult
      nx run charts-workspace:ci-distributed✅ Succeeded4m 47sView ↗
      nx run charts-workspace:package-check✅ Succeeded1m 45sView ↗
      nx run charts-workspace:benchmark-check✅ Succeeded47sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-11-04 20:29:57 UTC

    4. tannerlinsley merged this9dca5f1

    5. tannerlinsley closed this

Sign in to join this conversation.