Skip to content
InsightCharts

Search

Search guides and components

Unit blocks

Shows the size of each group as a solid block of small icons, one icon per fixed number of units.

Use when
Large counts of people or things in 2 to 12 groups, where the reader should see the crowd itself: 20,350 marathon finishers by age group, one figure per 10 runners.
Avoid when
Precise comparison of close values (use block bars or bar chart); fewer than about 30 icons per group (use pictogram chart or icon array grid); shares of one whole (use waffle chart).

Preview

Composition

Used in

1 infographic uses unit blocks.

Infographics

1

A poster that counts at scale. Blocks of thousands of unit icons fill most of the sheet, a second band counts reference groups with the same icon at the same size in a muted colour, and a bottom row holds three small graphics: squares sized by area with a ratio bracket, thick bars with the numbers inside, and shares as nested outlines or filled silhouettes.

Installation

$ pnpm dlx shadcn@latest add @insightcharts/unit-blocks

The CLI copies the source into your project and needs the @insightcharts registry in components.json; see installation. With the package, import it by name:

import { UnitBlocks } from "insightcharts";

Examples

Highlight, click to select

Stress: 20,350 icons, one per finisher

Columns of squares, coloured by a series field

Stress: twelve uneven groups, long names

Props

PropTypeDefaultDescription
namerequiredstringGroup field: one block of icons per row of data.
valuerequiredstringValue field: the quantity each block counts out.
unitnumberUnits per icon. Default: a round number that gives about 2,000 icons in total.
unitLabelstringWhat one icon stands for, for the key line, e.g. "10 finishers".
iconIconName | "path://...""person"Built-in icon name or a custom single SVG path.
seriesstringField that colours the blocks. Default: one colour per group, up to eight groups.
layout"packed" | "columns""packed"packed: equal block heights, widths follow the counts. columns: equal widths, blocks grow upwards from a baseline.
columnsnumberBlocks per line in the columns layout. Default: all, two on a phone.
iconSizenumberIcon height in px. Default: the largest that fits, chosen per chart. To put two charts on one scale, give both the same unit and iconSize: the icon size, the gaps and the worth of an icon are then identical and the chart takes the height it needs.
sort"none" | "asc" | "desc""none"Order of the blocks.
Common chart props 29

Every chart built with defineChart accepts these on top of its own props.

PropTypeDescription
dataDataInputRows, CSV text, a URL, { url, path }, an async function, or an Arrow-style table. Omit inside <InsightData>.
transformTransform | Transform[]A pipeline of transforms applied before drawing.
titlestringThe title. One plain statement of what the data shows, with the number and the period ("Monthly churn fell from 4.2% to 2.1% in 2024"), or a plain label ("Monthly churn, 2024"). One clause, no figures of speech.
subtitlestringMeasure, unit, population, period.
sourcestringData source, shown as "Source: ...".
notestringMethod notes or caveats.
heightnumber | stringCSS height of the plot. Default 360.
aspectnumberWidth / height. Overrides height.
highlightstring | string[]The entity (or entities) the title is about. Every other series is drawn in grey.
annotationsAnnotation[]Reference lines, shaded bands and callouts, in data coordinates.
formatFormatSpecHow to print values: "compact", "percent", "currency:USD", "{value} kg", Intl options, or a function.
legendbooleanShow the legend. Default: shown when there are two or more series.
selectboolean | stringMake marks clickable to filter. Inside <InsightData> the selection filters every other chart. Pass a field name, or true to use the chart's category field.
onSelect(values: string[], field: string) => voidCalled with the selected values whenever the selection changes.
optionEChartsOption | ((option: EChartsOption, ctx: BuildContext) => EChartsOption)Deep-merged over the generated ECharts option, or a function that receives and returns it. Use it for ECharts settings no prop covers.
themeThemeInputA theme, or a partial set of tokens merged over the surrounding theme, for this chart only.
modeModeInput"auto" (default) follows the page, "system" follows the OS, or force "light" / "dark".
rendererRendererInput"auto" (default) uses SVG for light charts and canvas for heavy ones.
animatebooleanSet false to disable animation. Reduced-motion preferences are always respected.
lazybooleanMount the chart only when it scrolls near the viewport. Default true.
groupstringLink tooltips with other charts sharing this group id.
exportableboolean | ExportFormat[]Show an export menu: true or a list of formats from png, jpeg, svg, pdf, csv, json.
tablebooleanShow a collapsible "View data" table under the chart.
altstringAccessible description: the chart type and measures, then the main pattern and the notable values.
idstringStable id for this chart's selection in the shared store.
onEventsRecord<string, ChartEventHandler>ECharts event handlers, e.g. { click: (params, chart) => {} }. Prefix a name with zr: to bind to the canvas itself.
onReady(chart: EChartsInstance) => voidCalled with the ECharts instance once it is created.
classNamestringClass name for the outer <figure>.
styleCSSPropertiesInline style for the outer <figure>.