hydroxy

Hexbin map

Points binned into hexagons over projected map shapes, each hexagon shaded by how many points fall inside. Reads density where individual dots would pile up.

Public charging sites
HexagonPointsTotalIncludes
Hexagon 113Aberdeen site 1
Hexagon 212Aberdeen site 2
Hexagon 316Aberdeen site 3
Hexagon 415Glasgow site 10
Hexagon 5210Edinburgh site 3, Edinburgh site 4
Hexagon 627Edinburgh site 5, Edinburgh site 8
Hexagon 727Glasgow site 4, Glasgow site 9
Hexagon 836Glasgow site 3, Glasgow site 5, Glasgow site 6
Hexagon 9316Glasgow site 1, Glasgow site 8, Glasgow site 12
Hexagon 10313Edinburgh site 2, Edinburgh site 6, Edinburgh site 9
Hexagon 1113Edinburgh site 7
Hexagon 1229Glasgow site 2, Glasgow site 11
Hexagon 1314Glasgow site 7
Hexagon 1413Edinburgh site 1
Hexagon 1515Newcastle site 2
Hexagon 1615Newcastle site 1
Hexagon 1711Newcastle site 3
Hexagon 1816Newcastle site 5
Hexagon 1917Newcastle site 6
Hexagon 2012Newcastle site 4
Hexagon 21210Belfast site 2, Belfast site 3
Hexagon 2212Belfast site 1
Hexagon 2316Belfast site 4
Hexagon 2413Belfast site 5
Hexagon 2526Leeds site 6, Leeds site 7
Hexagon 2611Leeds site 9
Hexagon 2738Manchester site 1, Manchester site 9, Manchester site 13
Hexagon 28526Manchester site 5, Manchester site 6, Manchester site 18, Leeds site 4, Leeds site 5
Hexagon 2929Leeds site 2, Leeds site 3
Hexagon 30311Leeds site 1, Leeds site 8, Leeds site 10
Hexagon 3114Manchester site 12
Hexagon 3227Manchester site 8, Manchester site 10
Hexagon 33419Manchester site 2, Manchester site 11, Manchester site 14, Manchester site 16
Hexagon 3424Manchester site 4, Manchester site 17
Hexagon 35314Manchester site 3, Manchester site 7, Manchester site 15
Hexagon 3626Birmingham site 5, Birmingham site 6
Hexagon 3713Birmingham site 1
Hexagon 3829Norwich site 2, Norwich site 4
Hexagon 3939Birmingham site 8, Birmingham site 10, Birmingham site 12
Hexagon 40314Birmingham site 2, Birmingham site 3, Birmingham site 4
Hexagon 4116Norwich site 1
Hexagon 4212Norwich site 3
Hexagon 43312Birmingham site 9, Birmingham site 13, Birmingham site 16
Hexagon 44312Birmingham site 7, Birmingham site 11, Birmingham site 15
Hexagon 4513Birmingham site 14
Hexagon 4628London site 19, London site 21
Hexagon 47212London site 10, London site 40
Hexagon 4814Cardiff site 2
Hexagon 49413Bristol site 1, Bristol site 2, Bristol site 5, Bristol site 9
Hexagon 5016Bristol site 7
Hexagon 51731London site 16, London site 24, London site 26, London site 28, London site 32, London site 38, London site 39
Hexagon 521356London site 2, London site 3, London site 5, London site 12, London site 15, London site 17, London site 18, London site 25, London site 27, London site 30, London site 33, London site 36, London site 37
Hexagon 53521London site 7, London site 13, London site 14, London site 23, London site 29
Hexagon 5428Cardiff site 1, Cardiff site 5
Hexagon 5528Bristol site 4, Bristol site 6
Hexagon 56319Bristol site 3, Cardiff site 3, Cardiff site 4
Hexagon 5715Bristol site 8
Hexagon 5813London site 6
Hexagon 59623London site 8, London site 9, London site 20, London site 22, London site 31, London site 35
Hexagon 60416London site 1, London site 4, London site 11, London site 34

Usage

use hydroxy_leptos::hexbin_map_chart::*;
use leptos::prelude::*;

/// A rough outline of Great Britain and Northern Ireland as (longitude, latitude).
fn uk() -> Vec<Region> {
    let gb = [
        (-5.7, 50.0),
        (-3.0, 50.6),
        (1.4, 51.2),
        (1.7, 52.7),
        (0.3, 53.4),
        (-0.1, 54.5),
        (-1.6, 55.6),
        (-2.1, 57.7),
        (-3.0, 58.6),
        (-5.0, 58.6),
        (-6.2, 56.8),
        (-5.6, 55.3),
        (-4.9, 54.8),
        (-3.4, 54.9),
        (-3.0, 53.4),
        (-4.6, 53.3),
        (-4.2, 52.3),
        (-5.3, 51.7),
        (-3.3, 51.4),
    ];
    let ni = [(-8.2, 54.4), (-7.3, 55.3), (-6.0, 55.2), (-5.4, 54.4), (-6.3, 54.0), (-7.6, 54.1)];
    vec![Region::new("gb", "Great Britain", f64::NAN, gb), Region::new("ni", "Northern Ireland", f64::NAN, ni)]
}

/// Charging sites scattered around towns: more around bigger towns, each with a few chargers.
fn sites() -> Vec<GeoPoint> {
    let towns = [
        ("London", (-0.13, 51.51), 40),
        ("Birmingham", (-1.89, 52.49), 16),
        ("Manchester", (-2.24, 53.48), 18),
        ("Leeds", (-1.55, 53.80), 10),
        ("Glasgow", (-4.25, 55.86), 12),
        ("Edinburgh", (-3.19, 55.95), 9),
        ("Bristol", (-2.59, 51.45), 9),
        ("Cardiff", (-3.18, 51.48), 5),
        ("Newcastle", (-1.61, 54.97), 6),
        ("Norwich", (1.30, 52.63), 4),
        ("Aberdeen", (-2.09, 57.15), 3),
        ("Belfast", (-5.93, 54.60), 5),
    ];
    // A fixed pseudo-random spread, so the demo looks the same every time.
    let mut seed = 7_u32;
    let mut next = move || {
        seed = seed.wrapping_mul(1_103_515_245).wrapping_add(12_345);
        f64::from(seed >> 8) / f64::from(1_u32 << 24) - 0.5
    };
    towns
        .iter()
        .flat_map(|&(town, (lon, lat), n)| {
            (0..n)
                .map(|k| {
                    GeoPoint::new(
                        format!("{town} site {}", k + 1),
                        (lon + next() * 1.2, lat + next() * 0.7),
                        (4.0 + next() * 6.0).round(),
                    )
                })
                .collect::<Vec<_>>()
        })
        .collect()
}

#[component]
pub fn Demo() -> impl IntoView {
    view! {
        <HexbinMapChart points=sites() regions=uk() label="Public charging sites" radius=14.0 projection=Projection::Mercator />
    }
}

Anatomy

Componentdata-partRenders
HexbinMapChartrootfigure; `data-active` while a hexagon is picked out
marksFocusable SVG; arrow keys step through hexagons from the top left
landThe base shapes, drawn plain
hexOne occupied hexagon, shaded by its point count through `--t`
tooltipPoints inside, their count and their summed value
scaleColour ramp from one point to the fullest hexagon
sr-tableEvery hexagon with its count, total and the names inside

Keyboard

KeyDoes
Arrow keysStep through hexagons
Home / EndFirst or last hexagon
EscapeClear the active hexagon

Props

PropTypeNotes
pointsVec<GeoPoint>Required. GeoPoint::new(name, (lon, lat), value); values sum into each hexagon's total
regionsVec<Region>Base shapes drawn under the hexagons; their values are ignored
labelStringRequired. What the map shows; the accessible name
radiusf64Hexagon radius in viewBox units (640 wide). Default 16
projectionProjectionEquirectangular (default), Mercator or Custom(fn)
formatFn(f64) -> StringFormats each hexagon's total

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