CandlestickChart
Financial OHLC candlestick chart
Source
LLM docs
Docs
Package
Usage
CandlestickChart is a financial chart that displays open, high, low and close (OHLC)
values as candles. The body of a candle shows the open–close range, the thin line shows
the high–low range.
Data
CandlestickChart requires an array of objects as the data prop. Set the dataKey
prop to the key that is used for the x-axis (category) values. By default, the chart
reads OHLC values from the open, high, low and close keys of each data object:
Unlike other charts, the y-axis does not start at zero: its domain is calculated from
the lowest and the highest values in the data. To change the domain, pass domain
through yAxisProps.
Custom data keys
If your data uses keys other than open/high/low/close, map them with the
dataKeys prop:
Colors
Use upColor and downColor props to change the colors of rising (close >= open)
and falling candles. Colors are referenced from theme the same way as in other components,
for example, blue, red.5, orange.7, etc. Any valid CSS color value is also accepted.
Candle width
By default, candles take up the available category width. Use the maxCandleWidth
prop to limit the maximum candle width in px:
Value formatter
To format values on the y-axis and inside the tooltip, use the valueFormatter prop.
It accepts a function that takes a number value as an argument and returns a formatted value:
Tooltip labels
The tooltip displays open, high, low and close values with English labels by default.
Use the labels prop to change them:
Axis labels
Use xAxisLabel and yAxisLabel props to display axis labels:
Reference lines
Use the referenceLines prop to render reference lines, for example to highlight
support and resistance levels: