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
Anatomie
Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.
<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.
- itemsrequisArray<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
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-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
Accessibilité
Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.
Rôles ARIA
Interactions clavier
| Touche | 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.
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
Custom legend entry
Vertical legend (right)
Écosystème
Famille
Composants du même dossier qui partagent les conventions et se composent souvent ensemble.
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.