Candlestick
Open, high, low and close per period, rising candles hollow and falling ones filled, the volume in its own panel, zoom and thresholds.
Web only — React, from @krizaka/charts/candlestick. Beta: its API may still change in a minor version.
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 Orochia auction's bids per hour, with the volume and the reserve price.
“Northern lights over Tadoussac” — bids per hour
Candlestick chart, 24 (12:00 AM – 11:00 PM). Opened at CA$120.00, closed at CA$228.60, low CA$111.70, high CA$229.50, up 91%.
| Category | Open | High | Low | Close | Bids |
|---|---|---|---|---|---|
| 12:00 AM | CA$120.00 | CA$120.00 | CA$115.20 | CA$115.20 | 4 |
| 1:00 AM | CA$115.20 | CA$122.40 | CA$111.70 | CA$118.80 | 8 |
| 2:00 AM | CA$118.80 | CA$119.70 | CA$114.20 | CA$117.00 | 12 |
| 3:00 AM | CA$117.00 | CA$128.10 | CA$114.90 | CA$123.60 | 16 |
| 4:00 AM | CA$123.60 | CA$126.60 | CA$122.20 | CA$124.80 | 7 |
| 5:00 AM | CA$124.80 | CA$130.20 | CA$119.90 | CA$120.60 | 11 |
| 6:00 AM | CA$120.60 | CA$127.50 | CA$120.60 | CA$124.80 | 15 |
| 7:00 AM | CA$124.80 | CA$124.80 | CA$120.10 | CA$123.60 | 6 |
| 8:00 AM | CA$123.60 | CA$134.40 | CA$120.80 | CA$130.80 | 10 |
| 9:00 AM | CA$130.80 | CA$133.50 | CA$128.70 | CA$132.60 | 14 |
| 10:00 AM | CA$132.60 | CA$137.10 | CA$127.60 | CA$129.00 | 5 |
| 11:00 AM | CA$129.00 | CA$135.60 | CA$128.30 | CA$133.80 | 9 |
| 12:00 PM | CA$133.80 | CA$139.20 | CA$133.20 | CA$133.20 | 13 |
| 1:00 PM | CA$133.20 | CA$143.70 | CA$129.70 | CA$141.00 | 4 |
| 2:00 PM | CA$141.00 | CA$143.40 | CA$138.20 | CA$143.40 | 8 |
| 3:00 PM | CA$143.40 | CA$147.00 | CA$138.30 | CA$140.40 | 12 |
| 4:00 PM | CA$140.40 | CA$155.70 | CA$139.00 | CA$154.80 | 16 |
| 5:00 PM | CA$154.80 | CA$168.30 | CA$154.10 | CA$163.80 | 7 |
| 6:00 PM | CA$163.80 | CA$183.00 | CA$163.80 | CA$181.20 | 11 |
| 7:00 PM | CA$181.20 | CA$198.60 | CA$177.70 | CA$193.20 | 15 |
| 8:00 PM | CA$193.20 | CA$202.50 | CA$190.40 | CA$199.80 | 6 |
| 9:00 PM | CA$199.80 | CA$214.80 | CA$197.70 | CA$214.80 | 10 |
| 10:00 PM | CA$214.80 | CA$228.00 | CA$213.40 | CA$224.40 | 14 |
| 11:00 PM | CA$224.40 | CA$229.50 | CA$223.70 | CA$228.60 | 5 |
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. |
titlerequired | string | — | What the chart shows, in a few words: its accessible name, and its heading unless hideTitle. |
xrequired | string | ((datum: T, index: number) => unknown) | — | The field of the period (a date, an hour). |
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/orazaka.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 | — | The "Show data" button (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[] | — | Export buttons: true for PNG, SVG and CSV, or the formats you want. |
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. |
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. |
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 2.4.0: its meta.ts, its examples and its types.Edit this documentation on GitHub