Candlestick
Open, high, low and close per period, rising candles hollow and falling ones filled, the volume in its own panel, zoom and thresholds.
- Domain
- Data display
- Support level
- Size
- Not measured
- Who uses it
- No live product imports it yet
import { Candlestick } from "@krizaka/charts/candlestick";Web only — React, from @krizaka/charts/candlestick. Beta: its API may still change in a minor version.
- Mobile · ✗ to build. Advanced tier: no phone screen needs it yet. issue #280
Why it is here. A financial chart: no product shows prices over time. Removed in the next major of @krizaka/charts (PS-C).
When to use
- A price that moves within each period: an auction's bids per hour, a credit's market price per day.
When not to use
- One value per period.Use instead: Line chart
Installation
Install
npm install @krizaka/chartsImport
import { Candlestick } from "@krizaka/charts/candlestick";Examples
Auction bids
An auction's bids per hour, with the volume and the reserve price.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
closerequired | string | ((datum: T, index: number) => number) | — | The field of the price at the end of the period. |
datarequired | readonly T[] | — | One row per period, oldest first. |
highrequired | string | ((datum: T, index: number) => number) | — | The field of the highest price of the period. |
lowrequired | string | ((datum: T, index: number) => number) | — | The field of the lowest price of the period. |
openrequired | string | ((datum: T, index: number) => number) | — | The field of the price at the start of the period. |
xrequired | string | ((datum: T, index: number) => unknown) | — | The field of the period (a date, an hour). |
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). |
columnLabels | { readonly open: string; readonly high: string; readonly low: string; readonly close: string; readonly volume: string; } | — | The words of the table's columns and the tooltip's rows. |
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. |
format | ValueFormat | — | How the prices and the volume are written. |
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”. |
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". |
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"). |
summaryText | string | — | Your own summary instead of the generated one (still read first by screen readers). |
thresholds | readonly Threshold[] | — | Horizontal lines: a reserve price, a target. |
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. |
volume | string | ((datum: T, index: number) => number) | — | The field of the volume: drawn in its own panel under the candles. |
volumeFormat | ValueFormat | — | How the volume is written. Default "compact". |
xFormat | CategoryFormat | — | How the periods are written. |
zoom | boolean | — | Zoom with the wheel and drag to pan. Default true from 40 periods. |
Accessibility
- The plot is a group named by the title and described by a summary written from the data, read before anything else.
- The data table is always in the page for assistive technology; “Show data” reveals it for everyone.
- The engine (ECharts core and this one chart type) loads when the chart nears the screen; a skeleton of the same height holds its place, so nothing shifts.
- Under reduced motion the chart is drawn without animation.
- Rising candles are hollow and falling ones filled: the shape says the direction, not only green and red.
Keyboard
| Keys | 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. |
Best practices
- Give the reserve or the target as a threshold.
- Past forty periods the chart zooms on the last forty; the wheel and a drag move through the rest.
Related components
Generated from the code of @krizaka/ui 5.3.4: its meta.ts, its examples and its types.Edit this documentation on GitHub