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

Anatomie

Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.

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

Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et description.

items
requis
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

Emplacements de contenu exposés par ce composant.

#legend-item
Replaces one legend entry entirely. Receives the series, its index and its current visibility.

API

Emits

Événements émis par ce composant.

@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

Accessibilité

Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.

Rôles ARIA

list
button

Interactions clavier

Interactions clavier
ToucheAction
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.

Interactif

Playground

Modifiez les props en direct et observez le composant se mettre à jour. Le snippet de code généré suit vos changements.

Rendu de l’aperçu en cours…

Usage

Exemples

Extraits de code prêts à coller dans vos templates.

Standalone legend

vue

Custom legend entry

vue

Vertical legend (right)

vue

Écosystème

Famille

Composants du même dossier qui partagent les conventions et se composent souvent ensemble.