CandlestickChart

Open, high, low and close of each period, the usual chart for prices. Each candle has a body from the open to the close, and a thin line from the lowest to the highest value.

Charts need Recharts. Install it once with yarn add recharts, then import from @bolio-ui/core/charts. The package stays out of your bundle until you use a chart.

General

Each row needs open, high, low and close. A rise has a hollow body and a fall has a solid one, so the direction does not rest on color alone.

Colors and keys

Use dataKeys when your rows name the values differently, labels to translate the tooltip, and upColor and downColor to pick the colors.

APIs

CandlestickChart.Props

AttributeDescriptionTypeAccepted valuesDefault
dataone row per periodArray<Record<string, ...>>--
dataKeykey of data that holds the x axis labelstring--
dataKeyskeys of the four values, when they are not the default names{ open, high, low, close }-open, high, low, close
heightheight of the chart, in pixelsnumber-300
upColorcolor of a period that closed at or above the openstring-theme success
downColorcolor of a period that closed below the openstring-theme error
withTooltipshow the four values on hover and focusboolean-true
withXAxisshow the x axisboolean-true
withYAxisshow the y axisboolean-true
withGridshow the horizontal grid linesboolean-true
labelsnames of the four values in the tooltip{ open, high, low, close }-Open, High, Low, Close
valueFormatterhow a number is written(value: number) => string-thousands separators, en-US
...native props, passed to the rootHTMLAttributes'aria-label', 'className', ...-

Ref

The ref points at the root div.

Accessibility

Name the chart with aria-label, or with aria-labelledby pointing at a heading. A named chart becomes a group. The chart can be focused. Arrow Left and Right then move through the data and show the values in the tooltip. The tooltip lists the open, high, low and close of the period.

A price chart carries many numbers, so offer the same data in a Table for anyone who needs the exact values.

Edit this page on GitHub