BUICharts

Charts/Diagram charts

HoneyComb

<HoneyComb /> · 10 examples

A hexagon per thing, coloured by how it is doing, packed to fill the panel.

1 / 10

Starting the chart engine…

Server load

One hexagon per server, coloured by threshold; the grid fills the space.

Overview

A rack of servers is a surprisingly hard thing to draw. A bar chart of 120 hosts is a comb with no teeth. A table of 120 rows is a table of 120 rows. What you want to know is almost always a single question about the whole fleet: how many are fine, and which are not?

The honeycomb answers it the way a bee would. Each host gets a cell, the cell takes a colour from your thresholds, and the cells are packed so that the whole panel is filled. There is no axis to read. There is a mostly green field with a few cells that are not, and your eye lands on them in about a quarter of a second. It is the same idea as a status grid, with the practical advantage that hexagons tile without leaving the slightly sad gaps that squares do at the edges.

Bees settled on hexagons because they use the least wax for the most storage. You will have a different reason: they look better on a wall monitor, and nobody has ever been asked to give up a hexagon.

Props

API

<HoneyComb data={servers} name={|s: &Server| s.name.as_ref()} value={|s: &Server| s.cpu} thresholds={steps} unit="%" />
PropTypeDefault
dataone row per cellrequired
name, valueFn(&T) -> &str, Fn(&T) -> f64required
thresholdsThresholdsgood below 80, bad above
min, maxf64: the range for percentage thresholds0., 100.
decimalsusizeas many as needed
unittext after the valuenone
columnsusize: cells per rowthe count that gives the largest cells

Hexagons in offset rows, coloured by threshold, with the value and name inside when they fit. Missing values are greyed out.

Run them

10 examples

Press Run to load an example into the live render at the top of the page. Open one to read its code.

  1. 01Server loadOne hexagon per server, coloured by threshold; the grid fills the space.
    #[component]
    fn servers() {
        let data = use_signal(items("web", 24, 1, 100.));
        rsx! { <HoneyComb data={data} name={|i: &Item| i.label.as_ref()} value={|i: &Item| i.value} thresholds={steps()} unit="%" class="h-80" /> }
    }
  2. 02Default thresholdsWithout thresholds, good below 80 and bad above.
    #[component]
    fn default_thresholds() {
        let data = use_signal(items("db", 12, 2, 100.));
        rsx! { <HoneyComb data={data} name={|i: &Item| i.label.as_ref()} value={|i: &Item| i.value} class="h-72" /> }
    }
  3. 03Percentage thresholdsSteps at 50% and 90% of a 2 000 GB range.
    #[component]
    fn percentage() {
        let data = use_signal(items("disk", 16, 3, 2000.));
        rsx! { <HoneyComb data={data} name={|i: &Item| i.label.as_ref()} value={|i: &Item| i.value} thresholds={Thresholds::percentage(vec![(f64::NEG_INFINITY, rgb(0x1e66f5)), (50., rgb(0x8839ef)), (90., rgb(0xd20f39))])} max={2000.} unit=" GB" class="h-72" /> }
    }
  4. 04Two decimalsdecimals fixes the value format.
    #[component]
    fn decimals() {
        let data = use_signal(
            items("node", 10, 4, 400.)
                .into_iter()
                .map(|item| Item {
                    value: item.value / 100.,
                    ..item
                })
                .collect::<Vec<_>>(),
        );
        rsx! { <HoneyComb data={data} name={|i: &Item| i.label.as_ref()} value={|i: &Item| i.value} decimals={2} thresholds={Thresholds::absolute(vec![(f64::NEG_INFINITY, rgb(0x40a02b)), (2., rgb(0xd20f39))])} class="h-72" /> }
    }
  5. 05Nine columnscolumns sets the grid width.
    #[component]
    fn fixed_columns() {
        let data = use_signal(items("pod", 18, 5, 100.));
        rsx! { <HoneyComb data={data} name={|i: &Item| i.label.as_ref()} value={|i: &Item| i.value} columns={9} thresholds={steps()} unit="%" class="h-56" /> }
    }
  6. 06Eighty servicesLabels hide when cells get small; hover to read them.
    #[component]
    fn crowd() {
        let data = use_signal(items("svc", 80, 6, 100.));
        rsx! { <HoneyComb data={data} name={|i: &Item| i.label.as_ref()} value={|i: &Item| i.value} thresholds={steps()} class="h-80" /> }
    }
  7. 07Three cellsA few large cells.
    #[component]
    fn few() {
        let data = use_signal(listed(&[("api", 42.), ("web", 77.), ("worker", 93.)]));
        rsx! { <HoneyComb data={data} name={|i: &Item| i.label.as_ref()} value={|i: &Item| i.value} thresholds={steps()} unit="%" class="h-64" /> }
    }
  8. 08Up or down0 and 1 as red and green.
    #[component]
    fn status() {
        let data = use_signal(items("check", 20, 7, 1.).into_iter().collect::<Vec<_>>());
        rsx! { <HoneyComb data={data} name={|i: &Item| i.label.as_ref()} value={|i: &Item| i.value} thresholds={Thresholds::absolute(vec![(f64::NEG_INFINITY, rgb(0xd20f39)), (1., rgb(0x40a02b))])} class="h-72" /> }
    }
  9. 09Endpoint latencyMillisecond steps at 100 and 300.
    #[component]
    fn latency() {
        let data = use_signal(listed(&[
            ("checkout", 120.),
            ("search", 45.),
            ("login", 310.),
            ("cart", 80.),
            ("profile", 60.),
            ("payments", 540.),
            ("images", 30.),
        ]));
        rsx! { <HoneyComb data={data} name={|i: &Item| i.label.as_ref()} value={|i: &Item| i.value} thresholds={Thresholds::absolute(vec![(f64::NEG_INFINITY, rgb(0x40a02b)), (100., rgb(0xdf8e1d)), (300., rgb(0xd20f39))])} unit=" ms" class="h-72" /> }
    }
  10. 10Missing valuesCells with no value are greyed out.
    #[component]
    fn missing() {
        let data = use_signal(
            items("host", 14, 8, 100.)
                .into_iter()
                .enumerate()
                .map(|(index, item)| Item {
                    value: if index % 5 == 2 { f64::NAN } else { item.value },
                    ..item
                })
                .collect::<Vec<_>>(),
        );
        rsx! { <HoneyComb data={data} name={|i: &Item| i.label.as_ref()} value={|i: &Item| i.value} thresholds={steps()} unit="%" class="h-72" /> }
    }

How to read it

  1. 01Look at the colour field first. A mostly uniform panel is good news. The question is which cells stand out.
  2. 02Find the outliers. Order is data order, so sort your data (by region, by rack, by value) if you want the outliers to cluster.
  3. 03Read the labels where they fit: the value on top and the name below. Where they do not fit, the cell is too small, and you can hover it instead.
  4. 04Grey cells have no value. Treat them as a separate category from green ones.

When to use it, and when not to

Reach for it when

  • You have tens to a few hundred similar things (hosts, pods, sensors, stores) and want the state of the whole set at a glance.
  • The question is "which ones are out of range?", not "what is the exact value?".
  • You have natural thresholds, such as good under 80% and bad above, and a colour per step is enough resolution.
  • You need the layout to adapt to whatever size the panel is: the grid shape recomputes itself.

Skip it when

  • You need to compare values precisely. Colour is a poor measuring tool. Use a Bar Gauge or a Lollipop.
  • The order of items carries meaning, such as time. Cells are laid out in data order, row by row, so position says nothing on its own. Use a Status History for samples over time.
  • You have thousands of cells. At that point each one is a few pixels, with no labels, and you are making a heatmap whether you meant to or not.
  • You want to see a distribution. A Histogram shows it directly.

The math behind it

Packing hexagons into a rectangle

Suppose you have nn cells, a drawing width WW and a height HH (the panel minus an 8 px margin). With cc cells per row there are r=⌈n/c⌉r = \lceil n / c \rceil rows. Odd rows are shifted half a cell to the right, so with more than one row the layout is c+12c + \tfrac12 cell-widths wide. For a hexagon of circumradius RR, the cell width is 3 R\sqrt{3}\,R and each row sits 1.5 R1.5\,R below the last.

The largest radius that fits is limited by whichever of the two dimensions runs out first. The chart tries every cc from 1 to nn and keeps the one with the largest RR, which is why the cells get bigger and the grid shape changes as you resize the panel. You can force cc with columns.

R(c)=min⁡ ⁣(W3 (c+12),  H1.5 r+0.5),r=⌈n/c⌉R(c) = \min\!\left(\frac{W}{\sqrt{3}\,(c + \tfrac12)},\; \frac{H}{1.5\,r + 0.5}\right), \qquad r = \lceil n/c \rceil

Colour

Each cell's colour comes from its value vv and the threshold steps. A step is the last one whose bound is not above vv. Percentage thresholds are turned into absolute values using min and max (0 and 100 by default), so "80%" means a+0.8 (b−a)a + 0.8\,(b - a) for a range [a,b][a, b].

A missing or non-finite value is not coloured as a zero: the cell is drawn in the theme's neutral grey at 40% opacity. That difference matters, because a host that has stopped reporting is not a host with a CPU of 0.

threshold(p%)=a+p100 (b−a)\text{threshold}(p\%) = a + \frac{p}{100}\,(b - a)

Text and drawing

The hexagon is drawn at 96% of the cell radius with a 1 px outline in the background colour, which is what produces the thin gaps between cells. The value and the name are written inside only when the cell is large enough (R>22R > 22 px and the text narrower than about 90% of the cell width). The value font is 0.34 R0.34\,R clamped between 9 and 26 px, and long names are cut and ended with an ellipsis. Hovering a cell shows a tooltip with its name and value.

Real life usage

Two hundred and eleven smoke detectors

Rosalind managed facilities for a chain of cold-storage warehouses, which meant a lot of sensors and a small team, and a standing rule that if a freezer door was left open, the cost was measured in prawns. Each of the 211 freezer units reported its temperature every minute to a central collector.

The old report was a spreadsheet exported every morning, with conditional formatting that had been painted red by somebody who clearly believed in the colour. It was a long column of numbers, and the units that mattered were hidden in the middle of it.

What she needed was a single view that a shift supervisor could glance at on the way to the loading dock: the whole estate, one mark per unit, and an immediate reading on which were warm. Order did not matter much. Presence of a problem did.

She built it with bui-charts: <HoneyComb> with the unit name as the label, the temperature as the value, and thresholds at -18 and -15 degrees, so anything warmer than -15 went red. She set unit="°C", left columns unset so the layout fitted the wall monitor, and sorted the data by site so that each warehouse formed its own patch.

On the second night, a patch of three cells in warehouse four turned amber, then red. It was a defrost cycle that had stuck. The supervisor saw it from across the dock, walked over and reset it. The temperature in those units had reached -14.2.

The spreadsheet had shown the same three rows the morning after, a day late. Over the next quarter the number of units that spent more than an hour above -15 fell from nineteen to four, and a small number of prawns, who have no say in this, were spared.

The old spreadsheet is still emailed every morning at six. Nobody has been able to find who set it up.

Pitfalls

  • Data order is layout order. Cells fill left to right, row by row. If your data is in random order, so is your panel, and patterns will not show.
  • Offset rows are not columns. Odd rows are shifted by half a cell, so the cell below is not directly under the one above. Do not read vertical alignment as meaning.
  • Resizing reflows the grid. Because the number of columns is picked to maximise cell size, the same data can be 12 across in a wide panel and 6 across in a narrow one.
  • Threshold direction. The defaults are good below 80 and bad above. For free space or battery, where low is bad, build the thresholds the other way round.
  • Tiny cells lose their text. With many cells in a small panel, labels disappear below about 22 px radius. That is the layout being honest. Either enlarge the panel or split it by group.

From around the web

Watch and read

How to Make a Hexagonal Cartogram in ArcGIS ProJohn Nelson MapsAbout hexagonal cartograms made with ArcGIS Pro, a neighbouring tool and technique that shares the hex-cell layout.