A mark-level renderer needs a ChartLayerRenderer with compose(defaultRenderer). The only public one is canvasChartRenderer.compose (canvas.ts:185-192). It wraps createLayeredChartRenderer (canvas.ts:439), which is not exported.
That function is not Canvas-specific. It splits scene nodes by node.renderer, mounts one child surface per run, and forwards render, paintFocus and presentation points. Adjacent nodes with the same renderer merge, so separate createSvgChartRenderer() instances give separate SVG layers.
Two costs today:
- Bundle. Using it for SVG-only layers pulls in the whole Canvas module (22 KB min, about 5.4 KB gzip).
- Paint. One shared
<svg> repaints as a whole while any group animates. With one <svg> per funnel stage (createSvgChartRenderer() instances plus compose: (d) => canvasChartRenderer.compose(d)), main-thread time per hover move fell from a median of 1.79 ms to 0.96 ms (production build, 12 interleaved rounds).
The docs describe the compositor only for Canvas (custom-marks-and-renderers.md:147).
Proposal#
Export it from a small module (for example @tanstack/charts/layers), or make it the default when compose is omitted. Document the layer wrapper (pointer-events: none, aria-hidden).
Checked against 57774e14a1a86081eddb3a23523724a40da05640 (v1.1.0).
Thanks for the detailed report, @toomingos. This shipped in #260 with 1.4.0, so I'm closing it. Custom SVG layers can now use
composeChartLayersfrom@tanstack/charts/layers. Please reopen with a small reproduction if the original SVG-only case still pulls in Canvas painting code.