Krizaka
Documentation

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.

WebBêtaGraphiques

Web uniquement — React, depuis @krizaka/charts/chart. Bêta : son API peut encore changer à une version mineure.

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/charts

Importer

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.

Uploads by hour of the day

Uploads by hour: quietest at 02:00 (1), busiest at 19:00 (61).

Uploads by hour of the day — data
HourUploads
00:003
01:002
02:001
03:001
04:002
05:004
06:009
07:0018
08:0026
09:0031
10:0034
11:0037
12:0041
13:0039
14:0036
15:0038
16:0044
17:0052
18:0058
19:0061
20:0049
21:0033
22:0017
23:008

Props

Any ECharts option, themed and framed like the typed charts. Memoise option when it is a function.

PropTypeDéfautDescription
optionrequisECBasicOption | ((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).
summaryTextrequisstring—The written summary: an option says nothing on its own.
tablerequisTableModel—The data as a table: the alternative of every chart.
titlerequisstring—What the chart shows, in a few words: its accessible name, and its heading unless hideTitle.
brandBrandId—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/orazaka.css).
classNamestring—A class on the figure (layout: margins, grid placement).
dataTableboolean—The "Show data" button (the table is in the page for screen readers either way). Default true.
descriptionReactNode—A sentence under the title: the period, the unit, the source.
emptyReactNode—What to show when there is nothing to draw (default: the empty label). An EmptyState of @krizaka /ui fits.
errorReactNode—The data could not be loaded: true says the default words, a node says yours (a retry button…).
exportableboolean | readonly ExportFormat[]—Export buttons: true for PNG, SVG and CSV, or the formats you want.
heightnumber—The height of the plot in pixels. Default 280 (a sparkline: 32).
hideTitleboolean—Visually hide the title (it stays the chart's accessible name): a card that already has its heading.
idstring—The id of the figure.
itemsreadonly WalkItem[]—What the arrow keys walk (series and data indexes, and what each one says).
labelsChartLabelsInput—The words, translated: the buttons, the states, the written summary.
liveboolean—Streaming data (a job queue, an auction): no entrance on updates, no announcement of every new point.
loadingboolean—The data is on its way: a skeleton of the chart, announced once.
localeLocale—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.
rendererRenderer—svg (default): sharp, exportable as SVG. canvas: for tens of thousands of marks.
styleCSSProperties—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").

Accessibilité

  • The plot is a group named by the title and described by summaryText.
  • Give items for the arrow keys to walk; without them the plot is not a tab stop.
  • table is the data table, always in the page for assistive technology.

Clavier

TouchesAction
TabMoves the focus to the plot (one tab stop), then to the data and export buttons.
Arrow keysWalk the items one by one: each is announced and highlighted, its tooltip shown.
Home / EndJump to the first or the last item.
EscHides the tooltip and clears the highlight.

Bonnes pratiques

  • Pass modules with only what the option needs (use([...]) in a module of yours): the default loads all of ECharts.
  • Write summaryText and table: an option is opaque, the alternative is yours to give.
  • Read the colours from the theme function (theme.palette, theme.text2), never hard-coded.

Générée depuis le code de @krizaka/ui 2.4.0 : son meta.ts, ses exemples et ses types.Modifier cette documentation sur GitHub

Sur cette page