Candlestick chart for financial OHLC data — pure SVG, zero JS.
Each candle has a vertical wick (high-low range) and a body (open-close range). Bullish candles (close >= open) are rendered in green; bearish candles (close < open) are rendered in red. Bullish bodies use a stroke-only style, while bearish bodies are filled solid.
Examples
<.candlestick_chart data={[
%{label: "Mon", open: 100, high: 110, low: 95, close: 108},
%{label: "Tue", open: 108, high: 115, low: 105, close: 103},
%{label: "Wed", open: 103, high: 112, low: 100, close: 111}
]} />
<.candlestick_chart
data={ohlc_data}
bullish_color="oklch(0.70 0.18 145)"
bearish_color="oklch(0.60 0.25 0)"
animate={true}
/>
Summary
Functions
Attributes
data(:list) - OHLC data:[%{label, open, high, low, close}]. Defaults to[].colors(:list) - Override default palette (unused for candlestick, use bullish/bearish_color). Defaults to[].bullish_color(:string) - Color for bullish candles (close >= open). Defaults to"oklch(0.70 0.18 145)".bearish_color(:string) - Color for bearish candles (close < open). Defaults to"oklch(0.60 0.25 0)".body_width(:any) - Override candle body width in px (auto-sized if nil). Defaults tonil.show_grid(:boolean) - Show Y-axis grid lines. Defaults totrue.show_labels(:boolean) - Show axis tick labels. Defaults totrue.animate(:boolean) - Enable entrance animations. Defaults totrue.animation_duration(:integer) - Animation duration in ms. Defaults to600.theme(:map) - Chart theme overrides (see ChartTheme). Defaults to%{}.id(:string) - Unique ID for the chart (auto-generated if not provided). Defaults tonil.title(:string) - Chart title rendered above the visualization. Defaults tonil.description(:string) - Chart description for context (rendered below title). Defaults tonil.class(:string) - Defaults tonil.- Global attributes are accepted.