hydroxy

Composed chart

Layer bars, lines, areas and points over the same categories and one value axis, such as orders with a rolling average. A crosshair reads every layer at once.

Orders

Monthly orders and returns, with the rolling average and promotion months.

Orders, returns and the rolling average by month
OrdersReturns3-month averagePromotion weeks
Jan312-24––
Feb288-19––
Mar341-28314341
Apr365-31331–
May402-26369–
Jun389-35385–
Jul420-30404420
Aug455-38421–
Sep431-33435–
Oct470-41452–
Nov512-45471512
Dec598-62527598

Traffic and signups

An area and bars on one axis.

Visits and signups by quarter
Visits (k)Signups
Q118296
Q2214121
Q3236118
Q4271154

Usage

use hydroxy_leptos::chart_frame::ChartFrame;
use hydroxy_leptos::composed_chart::*;
use leptos::prelude::*;

#[component]
pub fn Demo() -> impl IntoView {
    let months: Vec<String> =
        ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].map(String::from).to_vec();
    // Orders and returns as bars, the rolling average as a line, and promotions as points.
    let layers = vec![
        Layer::bar("Orders", [312.0, 288.0, 341.0, 365.0, 402.0, 389.0, 420.0, 455.0, 431.0, 470.0, 512.0, 598.0]),
        Layer::bar("Returns", [-24.0, -19.0, -28.0, -31.0, -26.0, -35.0, -30.0, -38.0, -33.0, -41.0, -45.0, -62.0]),
        Layer::line(
            "3-month average",
            [f64::NAN, f64::NAN, 314.0, 331.0, 369.0, 385.0, 404.0, 421.0, 435.0, 452.0, 471.0, 527.0],
        ),
        Layer::points(
            "Promotion weeks",
            [
                f64::NAN,
                f64::NAN,
                341.0,
                f64::NAN,
                f64::NAN,
                f64::NAN,
                420.0,
                f64::NAN,
                f64::NAN,
                f64::NAN,
                512.0,
                598.0,
            ],
        ),
    ];
    let quarters: Vec<String> = ["Q1", "Q2", "Q3", "Q4"].map(String::from).to_vec();
    let traffic = vec![
        Layer::area("Visits (k)", [182.0, 214.0, 236.0, 271.0]),
        Layer::bar("Signups", [96.0, 121.0, 118.0, 154.0]),
    ];

    view! {
        <div style="display: grid; gap: var(--space-10);">
            // Hover, or focus the plot and press Left/Right, to read every layer at once.
            <ChartFrame title="Orders" description="Monthly orders and returns, with the rolling average and promotion months." export=true>
                <ComposedChart
                    layers=layers
                    labels=months
                    label="Orders, returns and the rolling average by month"
                    curve=Curve::Monotone
                    annotations=vec![Annotation::y_line(450.0, "Target"), Annotation::x_band(10.0, 11.0, "Peak season")]
                />
            </ChartFrame>
            <ChartFrame title="Traffic and signups" description="An area and bars on one axis.">
                <ComposedChart layers=traffic labels=quarters label="Visits and signups by quarter" height=200 />
            </ChartFrame>
        </div>
    }
}

Anatomy

Componentdata-partRenders
ComposedChartrootfigure with a screen-reader table of every layer
gridlineRecessive gridlines at nice round ticks, always including zero
barBar layers sit side by side in each category; negative bars hang below zero
lineLine and area layers run through the category centres
pointA dot per value of a points layer
overlayFocusable plot that drives the crosshair
tooltipThe category and every layer's value
legendLayer names, with swatches shaped like each layer
annotationReference line, band or labelled point; x is a category index

Keyboard

KeyDoes
ArrowLeft / ArrowRightMove the crosshair one category
Home / EndJump to the first or last category
EscapeHide the crosshair

Props

PropTypeNotes
layersVec<Layer>Required. Layer::bar, Layer::line, Layer::area or Layer::points(name, values); NaN leaves a gap
labelsVec<String>Required. One label per category
labelStringRequired. What the chart shows; the accessible name
heightu16Plot height in px. Default 240
curveCurveLinear (default) or Monotone, for line and area layers
formatFn(f64) -> StringFormats ticks, tooltip and table
annotationsVec<Annotation>Reference lines, bands and labelled points; x is a category index

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
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