Skip to content

shadcn.io is an independent project built on shadcn/ui

Hexbin Density Map Block for Solid

An evening of cab pickups in London binned into hexagons on a live map. Switch the hexagon size, hover one to read its count and step from the busiest.

On this page5 sections
UI library: Ark UI

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Count points by area instead of drawing them all, with this hexbin density map for Solid with Ark UI. Hailcomb, a cab app's ops dashboard, takes an evening hour of pickups in central London, 562 of them round fourteen real stations and hubs from Paddington to Canary Wharf, and bins them into a grid of hexagons on a live Map that follows your theme, light or dark. Each hexagon is shaded by how many pickups fall inside it, in five steps of the theme's chart ramp named in the legend, and empty ones aren't drawn, so the grid's own shape shows where the cabs work. A Toggle Group over the map sets the size, 300 metres, 600 metres or 1.2 kilometres across: small hexagons show the noise, large ones the pattern, and the hexagon in focus stays in focus as the grid changes. Hover a hexagon to outline it and read its count, its rank and the nearest hub in the last of the three cells under the map; its arrows step through every hexagon from the busiest and fly the map to each. The other two give the hexagons in use, with the average pickups in each, and the busiest one, which a press flies to. Built from Map, Toggle Group, Button and Guides. For ride-hailing, delivery, retail footfall and any dashboard with too many points to read one by one.

FAQ

How are the points binned?

At module scope, once: each pickup is turned into metres from a point in the middle of the field, and the hexagon it falls in is found by rounding its axial coordinates (pointy-top hexagons, the size's corner radius). Pickups are counted per hexagon, the counts are sorted busiest first, and each hexagon is drawn as a six-cornered polygon with its count as a property. The three sizes are three grids built the same way, so switching between them only swaps the data the map draws.

Where do the pickups come from?

They're scattered by a seeded generator (Park-Miller), so every load and every target draws the same 562 points: each hub's pickups in a bell curve round it, and 60 more evenly over the field. The hubs are real places in London; Hailcomb and every pickup are invented, and nothing is fetched but the map's tiles. In your app, pass your own points to the same binning, or bin them on your server.

How are the colours chosen?

Each size has five steps of the theme's chart ramp, picked from its own counts (a 1.2 km hexagon holds many more pickups than a 300 m one), and the legend names each step's range. On a light theme busier is darker; on a dark theme the ramp turns round and busier is lighter. The outline of the hexagon in focus is drawn in the foreground colour on its own layer, so neighbours never cover it.

Can I read the hexagons without a mouse?

Yes. The last cell's arrows step through every hexagon from the busiest to the quietest, outline it, fly the map to it and read its count, rank and nearest hub; the Busiest hexagon cell is a button that goes straight to the first. The size toggle, the zoom buttons and the button that shows every pickup again are in the tab order. A polite message reads each new size or hexagon once the choice settles.

What happens to the chosen hexagon when I change the size?

The block finds the hexagon of the new size that holds the old one's centre and keeps it in focus, so the map stays where you were; if that new hexagon is empty, nothing is chosen and the map frames every pickup again.

How does it look on a phone?

The size toggle stays over the map's top, the legend moves to a row under it, and the first two cells sit side by side with the chosen hexagon's cell under them. Tapping a hexagon chooses it and reads its figures. Scrolling over the map scrolls the page: use two fingers to pan it, or the zoom buttons.