CandlestickCartesianLayer
Use CandlestickCartesianLayer
to create candlestick charts. Instantiate CandlestickCartesianLayer
via rememberCandlestickCartesianLayer
.
Each candle’s style is defined by its corresponding Candle
. The Candle
s are provided by a CandleProvider
:
absolute
. This is commonly used for filled candles and has such defaults.absoluteRelative
. This is commonly used for hollow candles and has such defaults.CandleProvider
.At the rememberCandlestickCartesianLayer
level, you can set the minimum body height, change the candle spacing, and toggle wick scaling.
Transaction.candlestickSeries
CandlestickCartesianLayer
s use CandlestickCartesianLayerModel
s. When using a CartesianChartModelProducer
, add CandlestickCartesianLayerModel
s via candlestickSeries
:
cartesianChartModelProducer.runTransaction {
candlestickSeries(
x = listOf(1, 2, 3, 4),
opening = listOf(2, 4, 6, 3),
closing = listOf(4, 5, 3, 3),
low = listOf(1, 4, 2, 2),
high = listOf(5, 6, 7, 4),
)
// ...
}
candlestickSeries
also has an overload with no x
parameter, which uses the indices of the prices as the x-values:
candlestickSeries(
opening = listOf(2, 4, 6, 3),
closing = listOf(4, 5, 3, 3),
low = listOf(1, 4, 2, 2),
high = listOf(5, 6, 7, 4),
)
CandlestickCartesianLayerModel
creationWhen creating a CartesianChartModel
directly, you can add a CandlestickCartesianLayerModel
by using build
:
CartesianChartModel(
ColumnCartesianLayerModel.build(
x = listOf(1, 2, 3, 4),
opening = listOf(2, 4, 6, 3),
closing = listOf(4, 5, 3, 3),
low = listOf(1, 4, 2, 2),
high = listOf(5, 6, 7, 4),
),
// ...
)
This function also has an overload with no x
parameter:
ColumnCartesianLayerModel.build(
opening = listOf(2, 4, 6, 3),
closing = listOf(4, 5, 3, 3),
low = listOf(1, 4, 2, 2),
high = listOf(5, 6, 7, 4),
)