hydroxy

Tree chart

A tidy node-link tree, top-down or left to right, with parents centred over their children. Click a branch to collapse or expand it, or move through it with the keys of a tree view.

Priya (CEO)Marcus (CTO)LenaTomAishaRaviDiegoMeiSamHannah (CFO)OliverGraceKofi (COO)InesYukiBenZaraNoah
Reporting lines
NodeValue
Priya (CEO)11 people
Priya (CEO) > Marcus (CTO)5 people
Priya (CEO) > Marcus (CTO) > Lena3 people
Priya (CEO) > Marcus (CTO) > Lena > Tom1 people
Priya (CEO) > Marcus (CTO) > Lena > Aisha1 people
Priya (CEO) > Marcus (CTO) > Lena > Ravi1 people
Priya (CEO) > Marcus (CTO) > Diego2 people
Priya (CEO) > Marcus (CTO) > Diego > Mei1 people
Priya (CEO) > Marcus (CTO) > Diego > Sam1 people
Priya (CEO) > Hannah (CFO)2 people
Priya (CEO) > Hannah (CFO) > Oliver1 people
Priya (CEO) > Hannah (CFO) > Grace1 people
Priya (CEO) > Kofi (COO)4 people
Priya (CEO) > Kofi (COO) > Ines3 people
Priya (CEO) > Kofi (COO) > Ines > Yuki1 people
Priya (CEO) > Kofi (COO) > Ines > Ben1 people
Priya (CEO) > Kofi (COO) > Ines > Zara1 people
Priya (CEO) > Kofi (COO) > Noah1 people
Priya (CEO)Marcus (CTO)LenaTomAishaRaviDiegoMeiSamHannah (CFO)OliverGraceKofi (COO)InesYukiBenZaraNoah
Reporting lines, left to right
NodeValue
Priya (CEO)11
Priya (CEO) > Marcus (CTO)5
Priya (CEO) > Marcus (CTO) > Lena3
Priya (CEO) > Marcus (CTO) > Lena > Tom1
Priya (CEO) > Marcus (CTO) > Lena > Aisha1
Priya (CEO) > Marcus (CTO) > Lena > Ravi1
Priya (CEO) > Marcus (CTO) > Diego2
Priya (CEO) > Marcus (CTO) > Diego > Mei1
Priya (CEO) > Marcus (CTO) > Diego > Sam1
Priya (CEO) > Hannah (CFO)2
Priya (CEO) > Hannah (CFO) > Oliver1
Priya (CEO) > Hannah (CFO) > Grace1
Priya (CEO) > Kofi (COO)4
Priya (CEO) > Kofi (COO) > Ines3
Priya (CEO) > Kofi (COO) > Ines > Yuki1
Priya (CEO) > Kofi (COO) > Ines > Ben1
Priya (CEO) > Kofi (COO) > Ines > Zara1
Priya (CEO) > Kofi (COO) > Noah1

Usage

use hydroxy_leptos::tree_chart::*;
use leptos::prelude::*;

fn team(lead: &str, people: &[&str]) -> Tree {
    Tree::branch(lead, people.iter().map(|p| Tree::leaf(*p, 1.0)).collect())
}

pub fn demo() -> AnyView {
    // Reporting lines; each person counts as one, so a branch's value is its headcount.
    let org = Tree::branch(
        "Priya (CEO)",
        vec![
            Tree::branch("Marcus (CTO)", vec![team("Lena", &["Tom", "Aisha", "Ravi"]), team("Diego", &["Mei", "Sam"])]),
            team("Hannah (CFO)", &["Oliver", "Grace"]),
            Tree::branch("Kofi (COO)", vec![team("Ines", &["Yuki", "Ben", "Zara"]), Tree::leaf("Noah", 1.0)]),
        ],
    );

    view! {
        <div style="display: grid; gap: var(--space-8);">
            <TreeChart root=org.clone() label="Reporting lines" format=|v: f64| format!("{v:.0} people") />
            <TreeChart root=org label="Reporting lines, left to right" orientation=Orientation::Horizontal height=420 />
        </div>
    }
    .into_any()
}

Anatomy

Componentdata-partRenders
TreeChartrootfigure with `data-orientation` and a screen-reader table of every node
marksFocusable SVG; arrow keys move through the tree
linkCurved line from a parent to a child
nodeDot and label; `data-collapsed`, `data-leaf`, `data-active`
tooltipName, value and how many children are shown or hidden
legendTop-level branches when there are two or more

Keyboard

KeyDoes
Up / DownPrevious or next visible node
RightExpand a collapsed branch, else move to its first child
LeftCollapse an open branch, else move to the parent
Home / EndFirst or last visible node
Enter / SpaceCollapse or expand the focused branch
EscapeClear the focused node

Props

PropTypeNotes
rootTreeRequired. Branch values come from their children
labelStringRequired. What the chart shows; the accessible name
orientationOrientationVertical (default, root at the top) or Horizontal (root on the left)
heightu16Plot height in px at an 800px drawing width. Default 360
formatFn(f64) -> StringFormats values in the tooltip and table

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