hydroxy

Connected scatter chart

Two measures plotted against each other and joined in time order, so the path shows how they moved together. The line draws itself from the first moment to the last.

Unemployment and inflation

Each dot is one year, joined in order from 2008 (hollow) to 2024 (solid).

Unemployment against inflation, 2008 to 2024
Unemployment rateInflation
20085.7%3.6%
20097.6%2.2%
20107.9%3.3%
20118.1%4.5%
20128.0%2.8%
20137.6%2.6%
20146.2%1.5%
20155.4%0.0%
20164.9%0.7%
20174.4%2.7%
20184.1%2.5%
20193.8%1.8%
20204.6%0.9%
20214.5%2.6%
20223.9%9.1%
20234.0%7.3%
20244.3%2.5%

Usage

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

pub fn demo() -> AnyView {
    // Annual averages: unemployment rate and consumer price inflation, both in percent.
    let years = [
        (2008, 5.7, 3.6),
        (2009, 7.6, 2.2),
        (2010, 7.9, 3.3),
        (2011, 8.1, 4.5),
        (2012, 8.0, 2.8),
        (2013, 7.6, 2.6),
        (2014, 6.2, 1.5),
        (2015, 5.4, 0.0),
        (2016, 4.9, 0.7),
        (2017, 4.4, 2.7),
        (2018, 4.1, 2.5),
        (2019, 3.8, 1.8),
        (2020, 4.6, 0.9),
        (2021, 4.5, 2.6),
        (2022, 3.9, 9.1),
        (2023, 4.0, 7.3),
        (2024, 4.3, 2.5),
    ];
    let data: Vec<Moment> = years.iter().map(|&(y, u, i)| Moment::new(y.to_string(), u, i)).collect();

    view! {
        <ChartFrame title="Unemployment and inflation" description="Each dot is one year, joined in order from 2008 (hollow) to 2024 (solid).">
            <ConnectedScatterChart
                data
                label="Unemployment against inflation, 2008 to 2024"
                x_label="Unemployment rate"
                y_label="Inflation"
                format_x=|v: f64| format!("{v:.1}%")
                format_y=|v: f64| format!("{v:.1}%")
                annotations=vec![Annotation::y_line(2.0, "2% target")]
            />
        </ChartFrame>
    }
    .into_any()
}

Anatomy

Componentdata-partRenders
ConnectedScatterChartrootfigure with a screen-reader table of every moment
lineThe path in time order; draws along its length
dotOne moment; data-end is start or end for the first and last
point-labelTime labels on a few points, always the first and last
axis-titleNames of the two measures
tooltipThe moment and both values

Keyboard

KeyDoes
ArrowLeft / ArrowRightEarlier or later moment
Home / EndFirst or last moment
EscapeHide the tooltip

Props

PropTypeNotes
dataVec<Moment>Required. Moment::new(label, x, y), in time order
labelStringRequired. What the chart shows; the accessible name
x_label / y_labelStringRequired. Names of the two measures
heightu16Plot height in px. Default 300
time_labelsusizeMost points to label with their time. Default 6
x_scale / y_scaleScaleKindLinear (default), Log or Symlog
format_x / format_yFn(f64) -> StringFormat each axis, the tooltip and table
annotationsVec<Annotation>Reference lines, bands and points in data units

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