hydroxy

Candlestick chart

Show open, high, low and close per period. A candle that closed at or above its open is green and one that closed lower is red. Candles with a volume add a volume strip underneath.

ACME daily prices
OpenHighLowCloseVolume
1 Sep$142.00$145.40$141.00$144.40800k
2 Sep$144.40$148.60$142.40$146.601.2M
3 Sep$146.60$153.67$143.60$150.671.5M
4 Sep$150.67$158.41$149.67$154.41890k
5 Sep$154.41$155.41$149.09$151.091.2M
6 Sep$151.09$153.09$145.55$148.551.6M
7 Sep$148.55$151.55$145.52$146.52980k
8 Sep$146.52$150.52$143.14$145.141.3M
9 Sep$145.14$151.52$142.14$150.521.7M
10 Sep$150.52$156.24$149.52$154.241.1M
11 Sep$154.24$158.23$152.24$155.231.4M
12 Sep$155.23$159.77$152.23$155.77800k
13 Sep$155.77$156.77$149.68$150.681.2M
14 Sep$150.68$152.68$146.14$148.141.5M
15 Sep$148.14$153.09$145.14$150.09890k
16 Sep$150.09$155.71$149.09$151.711.2M
17 Sep$151.71$158.22$149.71$157.221.6M
18 Sep$157.22$161.54$154.22$159.54980k
19 Sep$159.54$162.54$155.36$156.361.3M
20 Sep$156.36$160.36$152.74$154.741.7M
21 Sep$154.74$155.74$148.28$151.281.1M
22 Sep$151.28$153.28$150.11$151.111.4M
23 Sep$151.11$159.65$149.11$156.65800k
24 Sep$156.65$163.15$153.65$159.151.2M
25 Sep$159.15$162.51$158.15$161.511.5M
26 Sep$161.51$163.51$159.13$161.13890k
27 Sep$161.13$164.13$152.59$155.591.2M
28 Sep$155.59$159.59$153.52$154.521.6M
29 Sep$154.52$156.19$152.52$155.19980k
30 Sep$155.19$159.39$152.19$157.391.3M

Usage

use hydroxy_leptos::candlestick_chart::{Annotation, Candle, CandlestickChart};
use leptos::prelude::*;

#[component]
pub fn Demo() -> impl IntoView {
    // A 30-day run of daily prices with volume, from a deterministic wobble.
    let mut price = 142.0;
    let mut candles = Vec::new();
    let mut labels = Vec::new();
    for i in 0..30 {
        let t = f64::from(i);
        let open = price;
        let close = open + (t * 0.9).sin() * 4.0 + (t * 2.3).cos() * 2.0 + 0.4;
        let high = open.max(close) + 1.0 + f64::from(i % 4);
        let low = open.min(close) - 1.0 - f64::from(i % 3);
        let volume = 800_000.0 + f64::from((i * 37) % 11) * 90_000.0;
        candles.push(Candle::new(open, high, low, close).with_volume(volume));
        labels.push(format!("{} Sep", i + 1));
        price = close;
    }

    // A resistance level and the earnings week, by candle index.
    let levels = vec![Annotation::y_line(150.0, "Resistance"), Annotation::x_band(9.0, 13.0, "Earnings")];

    view! {
        // Hover, or focus the plot and press Left/Right, to read one day.
        // Scroll or pinch to zoom, drag to pan, or press + and − on the focused plot.
        <CandlestickChart
            candles=candles
            labels=labels
            label="ACME daily prices"
            format=|v: f64| format!("${v:.2}")
            annotations=levels
            zoom=true
        />
    }
}

Anatomy

Componentdata-partRenders
CandlestickChartrootfigure with a screen-reader table of every candle
columnsFocusable plot that drives the readout
wickThin line from the low to the high
bodyOpen to close; colour comes from the direction
tooltipOpen, high, low, close and volume of the active candle
volumeOptional strip of volume bars, tinted like their candles
crosshairDashed rule at the active candle's close, with its price in the gutter
annotationReference line, band or labelled point; x is a candle index
zoom-reset"Reset zoom" button, shown while zoomed

Keyboard

KeyDoes
ArrowLeft / ArrowRightMove to the previous or next candle
Home / EndJump to the first or last candle
EscapeHide the readout
+ / -With zoom: zoom in or out around the middle
Shift + ArrowLeft / ArrowRightWith zoom: pan
0With zoom: reset

Props

PropTypeNotes
candlesVec<Candle>Required. Candle::new(open, high, low, close), optionally .with_volume(v)
labelsVec<String>Required. One label per candle
labelStringRequired. What the chart shows; the accessible name
heightu16Price plot height in px. Default 260
volumeboolShow the volume strip when candles have volumes. Default true
formatFn(f64) -> StringFormats prices
annotationsVec<Annotation>Reference lines, bands and labelled points; x is a candle index, y a price
scaleScaleKindLinear (default), Log or Symlog price axis
zoomboolWheel or pinch to zoom, drag to pan, + / - and Shift+arrows on the focused plot. The price axis refits

Events

PropTypeNotes
on_hoverCallback<Option<Datum>>The mark under the pointer or keyboard focus changes, or is left. Fires only on a change
on_selectCallback<Datum>Click, tap or Enter on a mark
viewSignal<View>Controlled zoom window; share one signal to link charts. Uncontrolled when left off
on_view_changeCallback<View>Called once a zoom, pan or reset settles; not for changes that came from `view`
Actions
Button
Icon button
Toolbar
Theme menu
Display
Avatar
Badge
Card
Chip
Code block
Markdown
Doc card
Due pill
Kbd
Priority mark
Source chip
Space icon
Status diamond
Tag
Value diff
Carousel
Reveal
Media timeline
QR code
Transcript viewer
Audio waveform
Audio player
Forms
Calendar
Checkbox
Combobox
Date picker
Color picker
Cron builder
Theme editor
Mention input
Signature pad
Image cropper
Date field
Date range picker
Duration field
Quantity stepper
Filter chip
Input
Markdown editor
Radio group
Search field
Segmented control
Select
Slider
Range slider
Rating
Toggle button
File dropzone
Upload queue
Attachment
Switch
Tags input
Number field
Money field
Phone field
Time field
OTP input
Password field
Questionnaire
Availability picker
Voice input
Recording control
Inline edit
Async validated input
Shortcut recorder
Data
Spreadsheet grid
Week scheduler
Virtual list
Stat card
Step track
Kanban board
Sortable list
Filter builder
Data table
Grid
Access editor
File manager
Gantt chart
Log stream
Diff viewer
JSON inspector
Terminal
Node editor
Whiteboard
Navigation
Table of contents
Breadcrumb
Tabs
Wizard
Nav item
Nav section
Tree view
Pagination
Menubar
Navigation menu
Saved views
Layout
Master detail
App shell
Sidebar layout
Resizable panels
Dashboard layout
Dock layout
Feedback
Callout
Check list
Empty state
Progress bar
Toast
Approval card
Skeleton
Notification center
Bars
Bar chart
Diverging bar chart
Span chart
Pictogram chart
Stacked bar chart
Funnel chart
Bullet chart
Waffle chart
Marimekko chart
Dot plot chart
Error bar chart
Pareto chart
Waterfall chart
Lollipop chart
Grouped bar chart
Bar race chart
KPIs and frames
Chart frame
Metric card
Sparkline
Points
Scatter chart
Smith chart
Strip plot
Beeswarm chart
Parallel coordinates
Ternary chart
Bland-Altman chart
Quiver chart
Connected scatter chart
Grids and tables
Heatmap chart
Chart table
Cohort chart
Radial
Radial charts
Radar chart
Polar area chart
Stat ring
Clock chart
Spiral chart
Lines and areas
Bump chart
Slope chart
Line chart
Composed chart
Small multiples
Cycle plot chart
Horizon chart
Stacked area chart
Threshold chart
Split line chart
Linked charts
Confidence band chart
Forecast fan chart
Step chart
Range area chart
Distributions
Contour chart
Histogram
Box plot
Density chart
Ridgeline chart
Violin chart
Q-Q chart
Survival chart
ECDF chart
Raincloud plot
Forest plot
Maps
Geo map
Bubble map
Hexbin map
Cartogram
Flow map
Parts of a whole
Donut chart
Voronoi treemap
Nested donut chart
Treemap chart
Sunburst chart
Bubble pack chart
Icicle chart
Flame graph chart
Pie chart
Word cloud
Relationships
Sankey chart
Network chart
Chord chart
UpSet chart
Venn chart
Alluvial chart
Adjacency matrix chart
Dependency graph chart
Tree chart
Arc diagram
Hive plot
Edge bundling
Finance
Candlestick chart
OHLC chart
Depth chart
Renko chart
Time
Timeline chart
Calendar heatmap chart
Spectrogram chart
Marey chart
Overlays
Tour
Lightbox
Alert dialog
Command palette
Dialog
Menu
Popover
Tooltip
Sheet
Hover card
Context menu
Utilities
Pacer
Hotkeys
Disclosure
Accordion
Collapsible
Chat
Chat bubble
Voice session
Composer
Thread
Thread list
Assistant composer
Assistant MCP
Assistant modal
Assistant thread
Assistant thread list
Message scroller
Insight note
Emoji picker
Tool trace
Model picker
Citation popover
Activity
Activity feed
Comment thread
Timeline
Presence bar
Live cursors
Reaction bar
Guides
Getting started
All components
All charts