Chart (ECharts option)
Any ECharts option on the Krizaka frame: the theme resolved from the tokens, the lazy engine, the states, the table, the keyboard, the export.
- Domaine
- Affichage de données
- Niveau de support
- Taille
- Non mesurée
- Qui l'utilise
- Aucun produit en production ne l'importe encore
import { Chart } from "@krizaka/charts/chart";Web uniquement — React, depuis @krizaka/charts/chart. Bêta : son API peut encore changer à une version mineure.
- Mobile · n/a. The ECharts escape hatch needs the DOM; a phone draws the SVG charts of the native entry. → Line chart
Pourquoi il est là. The base the other charts are built on.
Quand l’utiliser
- A chart type the typed components do not cover: polar bars, a sunburst, a parallel axis, a graph.
Quand ne pas l’utiliser
- A type the package has: its props say more and its summary is written for you.À la place : Line chart
Installation
Installer
npm install @krizaka/chartsImporter
import { Chart } from "@krizaka/charts/chart";Exemples
Polar bars
Uploads per hour on a clock face: a type the package does not ship, with only its modules loaded.
Props
Any ECharts option, themed and framed like the typed charts. Memoise option when it is a function.
| Prop | Type | Défaut | Description |
|---|---|---|---|
optionrequis | ECBasicOption | ((theme: ResolvedTheme, size: { width: number; height: number; }) => ECBasicOption) | — | The ECharts option, or a function of the resolved theme (colours as plain strings, the palette, the ramp). |
summaryTextrequis | string | — | The written summary: an option says nothing on its own. |
tablerequis | TableModel | — | The data as a table: the alternative of every chart. |
actionsMenu | boolean | — | The ⋯ actions menu of the kit. false: the former “Show data” and export buttons, drawn in line. Default true. |
brand | BrandId | — | The brand whose palette the charts use. Without it, a chart follows a .brand-<id> ancestor, else Krizaka. Set it
when the app loads a brand stylesheet on :root (@krizaka/tokens/brands/sovkora.css). |
className | string | — | A class on the figure (layout: margins, grid placement). |
dataTable | boolean | — | “View as table” in the actions menu (the table is in the page for screen readers either way). Default true. |
description | ReactNode | — | A sentence under the title: the period, the unit, the source. |
empty | ReactNode | — | What to show when there is nothing to draw (default: the empty label). An EmptyState of
@krizaka /ui fits. |
error | ReactNode | — | The data could not be loaded: true says the default words, a node says yours (a retry button…). |
exportable | boolean | readonly ExportFormat[] | — | The downloads of the actions menu: all three by default, or the formats you want, or false for none. |
height | number | — | The height of the plot in pixels. Default 280 (a sparkline: 32). |
hideTitle | boolean | — | Visually hide the title (it stays the chart's accessible name): a card that already has its heading. |
id | string | — | The id of the figure. |
insight | ReactNode | — | One line that says what the chart shows, between the title and the chart: “100 jobs · +100 % vs last week”. |
items | readonly WalkItem[] | — | What the arrow keys walk (series and data indexes, and what each one says). |
labels | ChartLabelsInput | — | The words, translated: the buttons, the states, the written summary. |
live | boolean | — | Streaming data (a job queue, an auction): no entrance on updates, no announcement of every new point. |
loading | boolean | — | The data is on its way: a skeleton of the chart, announced once. |
locale | Locale | — | The locale of every figure and date ("fr-FR"). Default "en-US". |
modules | (() => Promise<unknown>) | () => import("../echarts/engines/full") | Registers what the option needs, from echarts/charts and echarts/components (tree-shaken):
() => import("./my-echarts") where that module calls use([...]). Default: all of ECharts (~380 kB gzip). |
onItem | ((item: { seriesIndex: number; dataIndex: number; }) => void) | — | A click (or Enter) on a data item. |
renderer | Renderer | — | svg (default): sharp, exportable as SVG. canvas: for tens of thousands of marks. |
style | CSSProperties | — | Inline style on the figure (layout only: colours come from the tokens). |
summary | "hidden" | "visible" | — | The written summary: read by screen readers only ("hidden", default), or shown under the chart ("visible"). |
title | string | — | What the chart shows, in a few words: its accessible name, and its heading unless hideTitle. Inside a ChartCard, the card's title is the default. |
Accessibilité
- The plot is a group named by the title and described by
summaryText. - Give
itemsfor the arrow keys to walk; without them the plot is not a tab stop. tableis the data table, always in the page for assistive technology.
Clavier
| Touches | Action |
|---|---|
| Tab | Moves the focus to the plot (one tab stop), then to the data and export buttons. |
| Arrow keys | Walk the items one by one: each is announced and highlighted, its tooltip shown. |
| Home / End | Jump to the first or the last item. |
| Esc | Hides the tooltip and clears the highlight. |
Bonnes pratiques
- Pass
moduleswith only what the option needs (use([...])in a module of yours): the default loads all of ECharts. - Write
summaryTextandtable: an option is opaque, the alternative is yours to give. - Read the colours from the theme function (
theme.palette,theme.text2), never hard-coded.
Composants liés
Générée depuis le code de @krizaka/ui 5.3.4 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub