ChartFrame
Responsive SVG chart shell — measures its width, applies plot margins, and hands the drawable plot geometry to a child snippet. The building block under every cartesian chart.
Playground
01 When to use
ChartFrame is the low-level shell every cartesian chart in the family is built on. It owns the
parts that are tedious to get right — responsive width via a ResizeObserver, plot margins, the viewBox, and the accessible role="img" wrapper — and hands you the measured plot geometry so you only draw the
marks.
Reach for it only when the chart you need isn't already in the family. For the common cases prefer the ready-made charts — they handle scales, axes, legends and tooltips for you:
LineChart/AreaChart— trends over a continuous axisBarChart— categorical comparisonsDonutChart— part-to-wholeSparkline— a tiny inline trend with no axes
Use ChartFrame directly for a bespoke mark type the family doesn't cover (a candlestick, a radial plot, a custom annotation layer) — you keep the responsive, accessible shell and own only the SVG inside it.
02 Examples
Custom marks
Legend & accessible fallback
| Day | Revenue (k€) |
|---|---|
| Mon | 12 |
| Tue | 19 |
| Wed | 15 |
| Thu | 24 |
| Fri | 21 |
Fixed width (SSR-stable)
03 Accessibility
- The SVG carries
role="img"with yourariaLabel, so assistive tech announces the chart as a single named image rather than reading out every path and number. - Because
role="img"hides the SVG internals, supply afallbacksnippet — rendered visually hidden — when the detail matters. A data<table>is the most robust choice. - The
legendsnippet is ordinary HTML below the SVG, so its text is selectable and in the accessibility tree without extra work. - Always pass an
ariaLabel. Without it the chart is an unlabelled image — fine only when an adjacent caption already conveys the same information.
API Reference
No matching properties |