ChartLegend
Standalone series-legend list shared by all chart families. Renders a colour swatch + series name per entry and handles click-to-toggle visibility.
Structure
Anatomy
Visual breakdown of the component's internal structure with BEM class call-outs.
<origam-chart-legend> — 4 internal parts. A pure renderer: receives pre-resolved items and emits toggle events.- 1.origam-chart__legend
- Root
- element. role="list". Flex layout: row when position=top|bottom, column when left|right.
- 2.origam-chart__legend-swatch
- with background-color from the resolved series colour. aria-hidden="true".
- 3.origam-chart__legend-label
- with the series name text.
- 4.origam-chart__legend-item--hidden
- BEM modifier when the series is hidden. opacity: 0.4 + text-decoration: line-through.
API
Props
All props accepted by this component, with their type, default value and description.
- itemsrequiredArray<IChartLegendItem>—
- Pre-resolved legend entries (series + index + colour + visibility). Comes from useChart().legend.value in the parent chart.
- positionTChartLegendPosition'bottom'
- Anchor of the legend block. Drives flex-direction: 'top' | 'bottom' = row; 'left' | 'right' = column.
API
Slots
Content slots exposed by this component.
- #legend-item
- Replaces one legend entry entirely. Receives the series, its index and its current visibility.
API
Emits
Events emitted by this component.
- @legend-clickIChartSeries, number
- Raw click on a legend entry. Pair with series-toggle to mutate state.
- @series-toggleIChartSeries, boolean
- Fires after a click with the intended next visibility value (inverted from current). The parent is responsible for actually mutating series.visible.
Inclusion
Accessibility
ARIA roles, keyboard navigation and focus management. Sourced from the real component template.
ARIA roles
Keyboard interactions
| Key | Action |
|---|---|
| Tab | Moves focus through each legend entry (tabindex="0"). |
| Enter / Space | Toggles the visibility of the focused series entry. |
Notes
- The root <ul> carries role="list" to preserve list semantics even when CSS resets remove list markers.
- Each item has aria-pressed="true|false" reflecting the current visibility state, and aria-label describing the action ("visible, click to hide" / "hidden, click to show").
- The colour swatch <span> carries aria-hidden="true" — it is purely decorative.
- A defensive filter removes entries missing the series ref before rendering — prevents SSR crashes when items arrive undefined.
Interactive
Playground
Edit props live and see the component update in real time. The generated code snippet updates as you change values.
Rendering the live preview…
Usage
Examples
Ready-to-paste code snippets for your templates.
Standalone legend
Custom legend entry
Vertical legend (right)
Ecosystem
Family
Components from the same folder that share conventions and often compose together.
Chart
Universal chart component supporting bar, line, area, pie, donut, scatter and more.
ChartBullet
Bullet chart — compact KPI display with range bands, actual-value bar and target tick.
ChartHeatmap
Rectangular heatmap chart with colour-mix gradient cells.
ChartHoneycomb
Hexagonal tile-map chart for categorical or heatmap data.
ChartMap
Choropleth and flight-route world map chart.