hydroxy

Grouped bar chart

Compare a few series within each category, side by side from zero. Vertical or horizontal, with negative values hanging below the baseline.

Signups by channel

Each quarter, side by side.

Signups by channel per quarter
OrganicPaidReferral
Q11240860310
Q214101020360
Q313801190455
Q416201080520

Operating margin

By region, this year against last.

Operating margin by region
20242025
North America18%21%
Western Europe12%14%
Asia Pacific6%10%
Latin America-4%2%

Usage

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

#[component]
pub fn Demo() -> impl IntoView {
    let quarters: Vec<String> = ["Q1", "Q2", "Q3", "Q4"].map(String::from).to_vec();
    let signups = vec![
        Series::new("Organic", [1_240.0, 1_410.0, 1_380.0, 1_620.0]),
        Series::new("Paid", [860.0, 1_020.0, 1_190.0, 1_080.0]),
        Series::new("Referral", [310.0, 360.0, 455.0, 520.0]),
    ];
    let regions: Vec<String> =
        ["North America", "Western Europe", "Asia Pacific", "Latin America"].map(String::from).to_vec();
    let margin = vec![Series::new("2024", [18.0, 12.5, 6.0, -4.5]), Series::new("2025", [21.0, 14.0, 9.5, 2.0])];

    view! {
        <div style="display: grid; gap: var(--space-10);">
            // Hover a bar to read its quarter; focus the plot and use the arrow keys.
            <ChartFrame title="Signups by channel" description="Each quarter, side by side.">
                <GroupedBarChart
                    categories=quarters
                    series=signups
                    label="Signups by channel per quarter"
                    annotations=vec![Annotation::y_line(1_500.0, "Organic target")]
                />
            </ChartFrame>
            // Horizontal keeps long names readable; negatives hang left of zero.
            <ChartFrame title="Operating margin" description="By region, this year against last.">
                <GroupedBarChart
                    categories=regions
                    series=margin
                    label="Operating margin by region"
                    orientation=Orientation::Horizontal
                    height=260
                    format=|v: f64| format!("{v:.0}%")
                />
            </ChartFrame>
        </div>
    }
}

Anatomy

Componentdata-partRenders
GroupedBarChartrootfigure with a screen-reader table of every value
gridlineRecessive gridlines at nice round ticks; the zero line is stronger
barOne per series and category, in categorical colour
overlayFocusable plot that drives the tooltip
tooltipThe category and every series' value, the active one in bold
annotationReference lines, bands and points
legendSeries names and colours, shown for two or more series

Keyboard

KeyDoes
ArrowLeft / ArrowRightNext or previous category (vertical); next or previous series (horizontal)
ArrowUp / ArrowDownNext or previous series (vertical); next or previous category (horizontal)
Home / EndFirst or last bar in the series
EscapeHide the tooltip

Props

PropTypeNotes
categoriesVec<String>Required. One label per group
seriesVec<Series>Required. Series::new(name, values); past six, the smallest fold into Other
labelStringRequired. What the chart shows; the accessible name
orientationOrientationVertical (default) or Horizontal
heightu16Plot height in px. Default 240
formatFn(f64) -> StringFormats ticks, tooltip and table
annotationsVec<Annotation>Annotation::y_line, y_band, x_line, x_band, point; 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