hydroxy

Cycle plot chart

Seasonal shape and trend in one chart. The axis is the periods of a cycle, such as months; inside each period a short line runs through that period's value in every cycle, such as every year, with a flat rule at their mean. The mean rules show the season; the slope of each mini line shows whether that month is changing.

Monthly rainfall, 2021 to 2025

Each month's line runs through its five years, oldest first; the flat rule is the five-year mean.

Monthly rainfall in millimetres, 2021 to 2025
20212022202320242025Mean
Jan88 mm79 mm92 mm84 mm90 mm87 mm
Feb61 mm70 mm58 mm66 mm63 mm64 mm
Mar52 mm49 mm61 mm55 mm50 mm53 mm
Apr41 mm46 mm49 mm52 mm44 mm46 mm
May58 mm51 mm47 mm55 mm49 mm52 mm
Jun49 mm54 mm44 mm47 mm39 mm47 mm
Jul47 mm38 mm52 mm41 mm36 mm43 mm
Aug63 mm52 mm58 mm49 mm47 mm54 mm
Sep55 mm64 mm69 mm74 mm78 mm68 mm
Oct79 mm86 mm95 mm101 mm108 mm94 mm
Nov84 mm91 mm97 mm104 mm110 mm97 mm
Dec92 mm88 mm85 mm94 mm97 mm91 mm

Covers by weekday

Average covers per day over the last six weeks. Weekends are growing fastest.

Café covers by weekday, weeks 38 to 43
Week 38Week 39Week 40Week 41Week 42Week 43Mean
Mon64616658636062
Tue71747068727571.7
Wed69727577808376
Thu78808488919586
Fri9610199108112118105.7
Sat142150139155161166152.2
Sun128131120126133129127.8

Usage

use hydroxy_leptos::chart_frame::ChartFrame;
use hydroxy_leptos::cycle_plot_chart::{CyclePlotChart, Series};
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();
    // Monthly rainfall in millimetres, one series per year. Autumn is getting wetter.
    let years = vec![
        Series::new("2021", [88.0, 61.0, 52.0, 41.0, 58.0, 49.0, 47.0, 63.0, 55.0, 79.0, 84.0, 92.0]),
        Series::new("2022", [79.0, 70.0, 49.0, 46.0, 51.0, 54.0, 38.0, 52.0, 64.0, 86.0, 91.0, 88.0]),
        Series::new("2023", [92.0, 58.0, 61.0, 49.0, 47.0, 44.0, 52.0, 58.0, 69.0, 95.0, 97.0, 85.0]),
        Series::new("2024", [84.0, 66.0, 55.0, 52.0, 55.0, 47.0, 41.0, 49.0, 74.0, 101.0, 104.0, 94.0]),
        Series::new("2025", [90.0, 63.0, 50.0, 44.0, 49.0, 39.0, 36.0, 47.0, 78.0, 108.0, 110.0, 97.0]),
    ];
    let days: Vec<String> = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"].map(String::from).to_vec();
    // Average covers per day at a café, one series per week over the last six weeks.
    let weeks = vec![
        Series::new("Week 38", [64.0, 71.0, 69.0, 78.0, 96.0, 142.0, 128.0]),
        Series::new("Week 39", [61.0, 74.0, 72.0, 80.0, 101.0, 150.0, 131.0]),
        Series::new("Week 40", [66.0, 70.0, 75.0, 84.0, 99.0, 139.0, 120.0]),
        Series::new("Week 41", [58.0, 68.0, 77.0, 88.0, 108.0, 155.0, 126.0]),
        Series::new("Week 42", [63.0, 72.0, 80.0, 91.0, 112.0, 161.0, 133.0]),
        Series::new("Week 43", [60.0, 75.0, 83.0, 95.0, 118.0, 166.0, 129.0]),
    ];

    view! {
        <div style="display: grid; gap: var(--space-10);">
            <ChartFrame
                title="Monthly rainfall, 2021 to 2025"
                description="Each month's line runs through its five years, oldest first; the flat rule is the five-year mean."
            >
                <CyclePlotChart periods=months cycles=years label="Monthly rainfall in millimetres, 2021 to 2025" format=|v: f64| format!("{v:.0} mm") />
            </ChartFrame>
            <ChartFrame title="Covers by weekday" description="Average covers per day over the last six weeks. Weekends are growing fastest.">
                <CyclePlotChart periods=days cycles=weeks label="Café covers by weekday, weeks 38 to 43" height=220 />
            </ChartFrame>
        </div>
    }
}

Anatomy

Componentdata-partRenders
CyclePlotChartrootfigure with a screen-reader table of every period and cycle
lineOne mini line per period, oldest cycle on the left
meanThe period's mean across cycles, a flat rule over its mini line
dotThe latest cycle's value in each period
x-labelPeriod names along the bottom
tooltipThe period, every cycle's value (the one under the pointer in bold) and the mean
legendThe span of cycles and the mean

Keyboard

KeyDoes
ArrowLeft / ArrowRightPrevious or next point, through every cycle of every period
Home / EndFirst or last point
EscapeHide the tooltip

Props

PropTypeNotes
periodsVec<String>Required. One label per period, such as the months
cyclesVec<Series>Required. One series per cycle, oldest first, with a value per period
labelStringRequired. What the chart shows; the accessible name
heightu16Plot height in px. Default 260
scaleScaleKindLinear (default), Log or Symlog; the axis fits the data, not zero
formatFn(f64) -> StringFormats ticks, tooltip and table
annotationsVec<Annotation>Reference lines, bands and points; x is a period 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