ChartLegend

Data Display
stable

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.

Anatomy of OrigamChartLegendSchematic of the ChartLegend component with 4 numbered internal parts. Revenue Costs Profit Margin 1 2 3 4 ④ --hidden modifier: opacity 0.4 + text-decoration: line-through
Anatomy of <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.

items
required
Array<IChartLegendItem>
—
Pre-resolved legend entries (series + index + colour + visibility). Comes from useChart().legend.value in the parent chart.
position
TChartLegendPosition
'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-click
IChartSeries, number
Raw click on a legend entry. Pair with series-toggle to mutate state.
@series-toggle
IChartSeries, 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

list
button

Keyboard interactions

Keyboard interactions
KeyAction
TabMoves focus through each legend entry (tabindex="0").
Enter / SpaceToggles 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

vue

Custom legend entry

vue

Vertical legend (right)

vue

Ecosystem

Family

Components from the same folder that share conventions and often compose together.