ComposedChart

A headless wrapper for a chart that combines several chart types, such as bars and a line, on shared axes. It gives the drawing the catalog's standard accessible shell: a named image plus an optional data-table alternative.

Status: beta — implemented and unit-tested in all eight headless libraries; not yet exercised in composed flows.

The component renders a <figure> holding a <div class="composed-chart-graphic" role="img" aria-label> around an inline <svg> that the consumer draws, and an optional sibling <div class="composed-chart-data-table"> for the accessible table. The component draws nothing and ships no scales, colours or animation.

Example

Sales and trend
Q1Sales 30, trend 36
Q2Sales 42, trend 46
Q3Sales 50, trend 56
Show demo markup
<figure class="composed-chart"><div class="composed-chart-graphic" role="img" aria-label="Composed chart: sales bars with a trend line"><svg viewBox="0 0 120 80" width="240" height="160" aria-hidden="true" focusable="false"><rect x="15" y="40" width="16" height="30" fill="currentColor" fill-opacity="0.4"/><rect x="45" y="28" width="16" height="42" fill="currentColor" fill-opacity="0.4"/><rect x="75" y="20" width="16" height="50" fill="currentColor" fill-opacity="0.4"/><polyline points="23,34 53,24 83,14" fill="none" stroke="currentColor" stroke-width="2"/></svg></div><div class="composed-chart-data-table"><table><caption>Sales and trend</caption><tbody><tr><th scope="row">Q1</th><td>Sales 30, trend 36</td></tr><tr><th scope="row">Q2</th><td>Sales 42, trend 46</td></tr><tr><th scope="row">Q3</th><td>Sales 50, trend 56</td></tr></tbody></table></div></figure>

Graphic only (no data table)

Show markup
<figure class="composed-chart"><div class="composed-chart-graphic" role="img" aria-label="Composed chart: sales bars with a trend line"><svg viewBox="0 0 120 80" width="240" height="160" aria-hidden="true" focusable="false"><rect x="15" y="40" width="16" height="30" fill="currentColor" fill-opacity="0.4"/><rect x="45" y="28" width="16" height="42" fill="currentColor" fill-opacity="0.4"/><rect x="75" y="20" width="16" height="50" fill="currentColor" fill-opacity="0.4"/><polyline points="23,34 53,24 83,14" fill="none" stroke="currentColor" stroke-width="2"/></svg></div></figure>
Usage example
<ComposedChart label="Describe the chart">
  <svg viewBox="0 0 100 100">…</svg>
  {#snippet dataTable()}
    <table><caption>Values</caption>…</table>
  {/snippet}
</ComposedChart>
Show Svelte source
// In your Svelte component:
import ComposedChart from "lily-design-system-svelte-headless/components/ComposedChart/ComposedChart.svelte";

<ComposedChart>
  <!-- content -->
</ComposedChart>

Usage

<ComposedChart label="Describe the chart">
  <svg viewBox="0 0 100 100">…</svg>
  {#snippet dataTable()}
    <table><caption>Values</caption>…</table>
  {/snippet}
</ComposedChart>

Props

Prop Type Default Description
class string "" Appended to the base class
label string (optional) — Accessible name of the image wrapper
children slot (required) — The consumer-drawn inline <svg>
dataTable slot (optional) — The accessible table alternative, rendered outside role="img"
...restProps HTML attributes — Spread onto the root <figure>

Keyboard Interactions

  • None on the graphic. The chart is a single image to assistive technology.
  • The data table follows native table behaviour.

ARIA

  • role="img" on the graphic wrapper exposes the chart as one image (its children are presentational)
  • aria-label provides the accessible name
  • The data table is outside role="img" so assistive technology can read it

When to Use

  • Several measures on shared axes, such as bars for volume with a line for a rate
  • Comparing a total and a trend together
  • When a real data table accompanies the drawing as the accessible alternative

When Not to Use

  • Use BarChart, ColumnChart or LineChart — a single measure or chart type is enough
  • Use ScatterChart — relationships between two measures
  • Use two separate charts — when the axes or units differ so much that sharing them confuses

Headless

This component decides semantics only: the figure element, the image role, the name and the table placement. It decides no geometry, scale, colour, legend or motion.

Styles

Target .composed-chart for the figure, .composed-chart-graphic for the image wrapper and .composed-chart-data-table for the table wrapper. Style the supplied <svg> from consumer CSS. No default styles are included.

Testing

  • Renders a <figure> with class composed-chart and a .composed-chart-graphic child with role="img"
  • label sets aria-label
  • The consumer svg renders inside the image wrapper
  • The data table renders in a .composed-chart-data-table sibling, outside role="img", only when supplied
  • Rest props reach the figure

Advice

Pass the combined drawing as one <svg>. Name each series in the accessible name or data table and make sure units are stated when the series use different scales.

Because role="img" makes descendants presentational, never put interactive controls inside the graphic; place legends and toggles next to it.

Implementation Notes

  • Renders <figure class="composed-chart {class}"> containing the image wrapper and, when supplied, the data-table wrapper
  • The consumer supplies the <svg> (and any legend markup that belongs inside the image)
  • restProps spread onto the <figure>
  • No internal state, no drawing, no data handling

Data table alternative (added 2026-10-05)

The graphic is wrapped in <div class="composed-chart-graphic" role="img" aria-label>; role="img" is not on the <figure>. The optional dataTable (a snippet in Svelte, a prop in React, a named slot in Vue, a projected [dataTable] element in Angular, a DataTable render fragment in Blazor, params.dataTable in Nunjucks, a slot="data-table" child in Web Components) renders the accessible table in <div class="composed-chart-data-table">, a sibling of the graphic and never inside it: role="img" makes its descendants presentational, so a table inside would be invisible to assistive technology. Without a data table the wrapper is not rendered (except Angular, which always renders an empty wrapper because it cannot detect projected content).

Related components

  • bar-chart
  • column-chart
  • line-chart
  • area-chart
  • graphic-block

Known limitations

None known.

References


Lily™ and Lily Design System™ are trademarks.

Canonical contract

Generated from this component's canonical metadata — the machine-checked source the implementations are held to.

Metadata

  • Component: composed-chart
  • PascalCase: ComposedChart
  • Description: a chart that combines several chart types, such as bars and a line, on shared axes
  • Status: beta — implemented and unit-tested in all eight headless libraries; not yet exercised in composed flows
  • HTML tag: <figure>
  • CSS class: .composed-chart
  • Interactive: no

ARIA

  • role="img" on the graphic wrapper exposes the chart as a single image
  • aria-label provides the accessible name

Keyboard

  • No keyboard interactions on the chart
  • A data table (when rendered) follows native table keyboard behaviour

Props

  • class: string (default: "") -- appended to the base class
  • label: string (optional) -- accessible name
  • children: slot (required) -- the inline <svg>
  • dataTable: slot (optional) -- the accessible table alternative
  • ...restProps: HTML attributes -- spread onto the root <figure>

Markdown

This page as Markdown, for people and AI tools: composed-chart.md