Krizaka UI
Krizaka UI
ComponentsData display

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.

Web · ✓Mobile · n/aDesktop · ✓BetaCharts
Support level
Beta
Size
Not measured
Who uses it
No live product imports it yet
import { Chart } from "@krizaka/charts/chart";

Web only — React, from @krizaka/charts/chart. Beta: its API may still change in a minor version.

  • Mobile · n/a. The ECharts escape hatch needs the DOM; a phone draws the SVG charts of the native entry. → Line chart

Why it is here. The base the other charts are built on.

When to use

  • A chart type the typed components do not cover: polar bars, a sunburst, a parallel axis, a graph.

When not to use

  • A type the package has: its props say more and its summary is written for you.Use instead: Line chart

Installation

Install

npm install @krizaka/charts

Import

import { Chart } from "@krizaka/charts/chart";

Examples

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.

PropTypeDefaultDescription
optionrequiredECBasicOption | ((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).
summaryTextrequiredstring—The written summary: an option says nothing on its own.
tablerequiredTableModel—The data as a table: the alternative of every chart.
actionsMenuboolean—The ⋯ actions menu of the kit. false: the former “Show data” and export buttons, drawn in line. Default true.
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/sovkora.css).
classNamestring—A class on the figure (layout: margins, grid placement).
dataTableboolean—“View as table” in the actions menu (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[]—The downloads of the actions menu: all three by default, or the formats you want, or false for none.
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.
insightReactNode—One line that says what the chart shows, between the title and the chart: “100 jobs · +100 % vs last week”.
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").
titlestring—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.

Accessibility

  • 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.

Keyboard

KeysAction
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.

Best practices

  • 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.

Generated from the code of @krizaka/ui 5.3.4: its meta.ts, its examples and its types.Edit this documentation on GitHub

On this page