hydroxy

Ternary chart

Compositions of three parts as points in a triangle. Each corner is all of one part; gridlines every 20% read off each share. Values are normalised, so any units work.

Soil texture

Sand, silt and clay by weight for each core sample.

Soil samples by texture
GroupPointSandSiltClay
Field AA142 g38 g20 g
Field AA245 g35 g20 g
Field AA338 g40 g22 g
Field AA450 g32 g18 g
Field BB120 g25 g55 g
Field BB215 g30 g55 g
Field BB322 g20 g58 g
Field BB418 g34 g48 g
Field CC170 g20 g10 g
Field CC265 g27 g8 g
Field CC375 g15 g10 g

Usage

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

#[component]
pub fn Demo() -> impl IntoView {
    let groups = vec![
        TernaryGroup::new(
            "Field A",
            [
                TernaryPoint::new("A1", 42.0, 38.0, 20.0),
                TernaryPoint::new("A2", 45.0, 35.0, 20.0),
                TernaryPoint::new("A3", 38.0, 40.0, 22.0),
                TernaryPoint::new("A4", 50.0, 32.0, 18.0),
            ],
        ),
        TernaryGroup::new(
            "Field B",
            [
                TernaryPoint::new("B1", 20.0, 25.0, 55.0),
                TernaryPoint::new("B2", 15.0, 30.0, 55.0),
                TernaryPoint::new("B3", 22.0, 20.0, 58.0),
                TernaryPoint::new("B4", 18.0, 34.0, 48.0),
            ],
        ),
        TernaryGroup::new(
            "Field C",
            [
                TernaryPoint::new("C1", 70.0, 20.0, 10.0),
                TernaryPoint::new("C2", 65.0, 27.0, 8.0),
                TernaryPoint::new("C3", 75.0, 15.0, 10.0),
            ],
        ),
    ];

    view! {
        <ChartFrame title="Soil texture" description="Sand, silt and clay by weight for each core sample.">
            <TernaryChart groups=groups label="Soil samples by texture" a_label="Sand" b_label="Silt" c_label="Clay" format=|v: f64| format!("{v:.0} g") />
        </ChartFrame>
    }
}

Anatomy

Componentdata-partRenders
TernaryChartrootfigure with a screen-reader table of every point
plotFocusable triangle; arrow keys step through points
gridlineLines of equal share for each part, every 20%
tickShare labels: A on the left edge, B along the bottom, C on the right
cornerPart names at their corners
dotOne per point, in its group colour
tooltipEach share with its raw value
legendGroup names, shown for two or more groups

Keyboard

KeyDoes
ArrowRight / ArrowLeftNext or previous point
Home / EndFirst or last point
EscapeClear the active point

Props

PropTypeNotes
groupsVec<TernaryGroup>Required. TernaryGroup::new(name, points); TernaryPoint::new(label, a, b, c)
labelStringRequired. What the chart shows; the accessible name
a_label / b_label / c_labelStringRequired. Names of the three parts
sizeu16Triangle width in px. Default 360
formatFn(f64) -> StringFormats raw 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