When to Use
- Stock prices: Display daily/weekly/monthly OHLC data
- Cryptocurrency: Track volatile crypto markets
- Commodity prices: Visualize oil, gold, or agricultural futures
- Trading signals: Overlay indicators on candlestick charts
- Any OHLC data: When four-value encoding is needed per time period
Basic Example
Input Modes
Categorical Mode: with_candle
Candles are placed at evenly spaced integer positions; labels shown as x-axis ticks.
Numeric Mode: with_candle_at
Each candle placed at an explicit f64 x position on a continuous numeric x-axis.
Key Methods
with_candle(label, open, high, low, close)
Append a candle in categorical mode. Parameters accept any type implementing Into<f64>.
with_candle_at(x, label, open, high, low, close)
Append a candle at explicit x position in numeric mode.
with_candle_width() to set body width in data units (e.g. 0.15 for quarterly data).
Volume Panel
with_volume(volumes: impl IntoIterator<Item = T>)
Attach volume values to candles in insertion order.
with_volume_panel() is also called.
with_volume_panel()
Enable the volume bar panel below the price chart.
with_volume_ratio(ratio: f64)
Set fraction of total chart height used by volume panel (default 0.22).
Styling
with_candle_width(width: f64)
Set candle body width as fraction of slot (categorical mode) or in data units (numeric mode). Default 0.7.
with_wick_width(width: f64)
Set wick stroke width in pixels (default 1.5).
with_color_up(color: impl Into<String>)
Set color for bullish candles where close > open (default "rgb(68,170,68)" — green).
with_color_down(color: impl Into<String>)
Set color for bearish candles where close < open (default "rgb(204,68,68)" — red).
with_color_doji(color: impl Into<String>)
Set color for doji candles where close == open (default "#888888" — gray).