Charts

Charts 53 chart types, 50 with payloads + live samples — cartesian, categorical, part-to-whole, distribution, trend, flow, network, multivariate, goal, geographic. Reference · charts ## Chart variants {#charts} The `chart` primitive accepts 53 values for `type`. Fifty of them get a worked section on this page — payload plus live render. The three without one are `plot` and `arc`, the base modes the element sets on itself rather than taking from an author, and `geo`, which is an alias the tile-map section covers. Reach for a type by intent — the families below cluster types that solve the same shape of problem. Each card has a tiny live preview; click through to the variant for its full payload and a live render. ### chart {#chart} Single primitive, many render modes via the `type` field. The Cartesian family (`scatter`, `line`, `area`, `bubble`, `quadrant`) share an interactive SVG plot with pan / zoom / log axes / PNG export. The bar family (`bar`, `stacked-bar`, `grouped-bar`) renders horizontal CSS bars. `donut` renders a distribution arc. The renderer dispatches by `type` — each mode has its own payload shape; unused fields are ignored. > [!INFO] Library underneath > All modes are kit-native — no third-party chart library. Cartesian + donut modes render as inline SVG drawn by the oku-chart Custom Element. The bar family renders as plain HTML + CSS, no JavaScript after first paint. ### Pick by function {#chart-families} 43 of the types, grouped by what you're trying to say. Click any card to jump to the variant's full example — the live tiny render previews the shape. The families further down carry all 50. #### Compare {#chart-fn-compare} Bars, dots-vs-targets, radial spokes — anything that lines values up side by side so the reader can compare magnitudes. #### Trend {#chart-fn-trend} Continuous trends or cyclic patterns where the x-axis is time. #### Distribution {#chart-fn-distribution} Where values cluster, what the spread looks like, how peaks compare across categories. #### Composition {#chart-fn-composition} One total, broken into named slices that add up to it. Pick the shape to match how many parts you have and whether the centre matters. #### Relationship {#chart-fn-relationship} How one variable depends on another — pairs, matrices, links between entities. #### Hierarchy {#chart-fn-hierarchy} Nested containment — a thing inside a thing inside a thing. #### Flow {#chart-fn-flow} Quantity moving from one place to another — funnel stages, weighted source→target links. #### Location {#chart-fn-location} Values laid out on a coarse tile grid that approximates the world by region. NOT a real choropleth — every region is a fixed-size tile labelled by its ISO code. Use when the reader needs to scan regional differences at a glance without the visual budget (or the topojson dependency) of a real map. ## Cartesian — x/y points with axes {#family-cartesian} Use when the x-axis is a continuous quantity (or ordered sequence) and you want to show position, slope, or relationships between two numeric dimensions. ### type: scatter {#chart-scatter} One or more series of {x, y} points — no connecting line, just dots. Per-point label optional (shown on hover). Per-series colour drawn from the accent / warn / danger / success / muted vocabulary. Axes auto-scale; pass x-scale=log / y-scale=log on the element for log axes. ### type: line {#chart-line} Same series-of-points contract as scatter — but the renderer connects consecutive points with a polyline. Use when the x-axis is ordered (time, build-number, sequence) and the reader should see slope, not just position. Two or more series stack on the same axes; legend chips at the top-right toggle visibility. Add `"curve": "smooth"` for a Catmull-Rom spline through the points (default is `linear`); applies to `type: area` too. ### type: area {#chart-area} Same shape as line — series of {x, y} points — but the curve is filled down to the baseline. Useful for cumulative metrics over time where magnitude matters as much as direction. ### type: bubble {#chart-bubble} Scatter plot with a third dimension encoded as dot size. Each point gains an optional `size` field; the renderer takes its square root so the dot's AREA is proportional to size (eye reads area, not radius). Useful for cost vs. impact vs. confidence-style decision matrices. ### type: quadrant {#chart-quadrant} Scatter plot split into four regions by two reference lines. Author supplies a `quadrants` block with `x` (vertical split) + `y` (horizontal split) and optionally four corner labels (`[TL, TR, BL, BR]`). Reads as a 2×2 decision matrix at a glance. ### type: connected-scatter {#chart-connected-scatter} Scatter where consecutive points are joined by a line in series order — a trajectory through 2-D space. Same `series` shape as scatter; sequence is the per-series data order. The start point renders as a hollow ring, the end point as a filled square so direction reads at a glance. Use when two metrics move together over time (life expectancy × income across years, MAU × ARPU across releases). ## Categorical — value per category {#family-categorical} One bar per item, optionally split into stacks or sub-groups. Use when each row has a single label and value; reach for stacked/grouped when each row has multiple comparable values. ### type: bar {#chart-bar} Row-per-item horizontal bars. Each row carries `label`, `value`, optional `display` (right-hand readout override), and optional `color` (accent / warn / danger / success). `max` caps the bar full-width; if omitted, the largest row's value sets the scale. Use when you want a label/value comparison without axis chrome. ### type: stacked-bar {#chart-stacked} Multi-series horizontal bars where each row's series stack into a single bar. Author supplies `categories` (one per row) and `series` of `{label, color, values}`, with `values[i]` aligning to `categories[i]`. The right-hand readout is the row total. Use for breakdown-of-a-total visualisation. ### type: grouped-bar {#chart-grouped} Same payload as stacked-bar, but each series renders as its own thin sub-bar within the row rather than stacking. Use for direct comparison across series within the same category. ### type: dot-plot {#chart-dot-plot} One row per category, a single dot at the value. Compact comparison shape — like a horizontal bar stripped to just the endpoint. Use when bar length itself adds visual noise (ratios near each other, ordered lists). ### type: marimekko {#chart-marimekko} Variable-width stacked bar — each column's WIDTH is proportional to that column's total, so the chart shows both within-column proportions AND across-column magnitudes in one view. ### type: waterfall {#chart-waterfall} Incremental gains and losses connecting two totals. Start bar + positive/negative steps + end bar; dashed bridges link cumulative tops. Canonical 'what changed between these two numbers' chart — financial bridge, retention loss-explanation, performance breakdown. ### type: lollipop {#chart-lollipop} Variant of dot-plot — same data shape, with a thin stem from the axis to the dot. Reads as a less-noisy bar chart when the value comparison is the headline. ### type: dumbbell {#chart-dumbbell} Two dots per category joined by a line — before/after, men/women, 2010/2020. Compact alternative to the slope chart when many categories don't fit a slope layout. Connector colour signals direction (success up, danger down). ### type: population-pyramid {#chart-population-pyramid} Two diverging horizontal bar groups around a shared centre column of category labels. `left.values[]` grows leftward, `right.values[]` grows rightward, both aligned to `categories`. Use for demographic pyramids (men vs women per age bucket) or any two-sided comparison sharing a row axis (revenue vs cost per region, inbound vs outbound per channel). ### type: range-bar {#chart-range-bar} One row per item; each row carries a `[low, high]` interval drawn as a horizontal band with optional `mid` tick. Use when the *interval* is the data — confidence intervals, election polls (margin of error), salary ranges, price floors and ceilings, error bars in summary form. The right-hand readout shows the numeric range; hover surfaces low / high / mid in the tooltip. ### type: pareto {#chart-pareto} Bars sorted descending by `value` + a cumulative-percentage line on a secondary axis. The classic 80/20 reading shape — surfaces "the top N causes account for 80% of the total" in operations, defect root-cause audits, support-ticket triage. The renderer sorts rows for you; the dashed 80% guide reads against the right-hand percentage axis. ## Part-to-whole {#family-partwhole} A whole divided into named slices. Donut + pie are the classic choices; waffle reads better when the absolute count matters; treemap when the parts have a hierarchy. ### type: donut {#chart-donut} Single-ring distribution chart. Each `slice` is a `{label, value, color?}`; the renderer normalises values to percentages of the total, draws an arc per slice, and shows the total + a legend on the side. ### type: pie {#chart-pie} Same `slices` payload as donut; the only difference is the absence of the centre hole and the centre-readout. Reach for pie when the part-to-whole relationship is the whole story and the absolute total doesn't need an extra glance. Pie reads better than donut for 2–4 slice distributions; for 5+ slices, prefer donut (clearer per-slice legend strip) or stacked-bar. ### type: waffle {#chart-waffle} Dot-matrix breakdown. Default 10×10 grid (= 100 cells). `segments` is a list of `{label, count, color}`; the renderer fills cells in order, one per unit count. The legend lives to the right of the grid with the percentage of each segment. ### type: treemap {#chart-treemap} Area-proportional nested rectangles via squarified layout. `tree[]` is a flat list of `{label, value, color?}` leaves; the largest values occupy the largest rectangles. Labels render only when the rectangle is large enough to fit them legibly. Use for composition (LoC by language, spend by category, traffic by route). ### type: sunburst {#chart-sunburst} Radial hierarchy. Concentric arcs per depth ring; arc length proportional to node value sum. Like a treemap but radial — reads better for shallow, broad trees with named outer leaves. ### type: polar-area {#chart-polar-area} Bars laid out around a circle. Cyclical categorical data (days of week, months, hours of day, compass directions) where the cyclic shape itself carries meaning. Distinct from radar — radar = filled polygon over multi-vars; polar-area = sector per category. ## Distribution shape {#family-distribution} How a value's frequency is spread, not its total. Histogram for binned counts; box-plot for quartile summary; ridgeline to compare multiple distributions vertically. ### type: histogram {#chart-histogram} Frequency by bin. Author supplies the binning (`bins[]` with `{lo, hi, count}`). Contiguous bins read as a connected distribution; gaps are allowed but render with the visible gap. Use for distribution shape, latency tail, time-to-event. ### type: box-plot {#chart-box-plot} Quartiles + whiskers + optional outliers — one row per `boxes[]` entry. Required: `min`, `q1`, `median`, `q3`, `max`. Optional: `outliers: [Number]` rendered as dots beyond the whiskers. ### type: ridgeline {#chart-ridgeline} Stacked small-distributions, one per row. `distributions[].values` is a flat sample; the renderer bins each sample into ~30 buckets over the global range. Read for shape comparison across groups (per-region latency, per-cohort engagement). ### type: density {#chart-density} Smoothed histogram via Gaussian KDE. Reads like a histogram without the bin-boundary artefacts. Default bandwidth is Silverman's rule; override with bandwidth for tighter or smoother curves. ### type: violin {#chart-violin} Kernel-density box-plot alternative. Per-distribution mirrored density curve (the violin body) + IQR rectangle + median line. Shows shape AND quartiles where the box-plot only shows quartiles. ### type: beeswarm {#chart-beeswarm} One-axis distribution rendered as jittered dots, one per data point. Vertical placement is force-balanced so dot density at any x-position visually encodes count. Reads more honestly than a histogram for small samples. ### type: hexbin {#chart-hexbin} Tile the plot region with hexagonal cells; each cell's opacity encodes how many `points[]` fall inside. Use when a scatter would overplot — 10⁴+ samples where individual dots lose meaning and only density matters. `radius` controls cell size in viewBox px; smaller → finer resolution but noisier; bigger → smoother map but loses local detail. ## Trend over time {#family-trend} Sequence on the x-axis, value on the y. Sparkline for in-line micro-trends; slope for before/after pairs; calendar-heatmap for day-of-year × day-of-week activity. ### type: sparkline {#chart-sparkline} Inline mini line / area / bar. No axes, no chrome — sized for the line height of surrounding prose. `values` is a flat numeric series. `variant` picks line (default), area (filled), or bar (per-value mini-bars). `end_label` renders to the right of the curve as a small caption (`62%`, `↗`, etc.). Column variant — same flat `values` payload, set `"variant": "bar"` for per-value mini-bars. Use when each value is a discrete event (a count per day, hits per minute) rather than a continuous trend. ### type: slope {#chart-slope} Two-time-point change — left column is `from`, right column is `to`, one slope line per `items[]` entry. The renderer auto-colours rising as success and falling as danger unless an explicit `color` is set. Use this when ‘who went up, who went down’ is the question. ### type: calendar-heatmap {#chart-calendar-heatmap} Year-in-cells activity grid. `date_values` is a map of ISO date → numeric value; days missing from the map render faintly to show the calendar shape. Mon, Wed, Fri labels along the left; month names along the top at the first cell of each month. ### type: candlestick {#chart-candlestick} Financial OHLC. Each entry is one trading period; up days (close ≥ open) in success colour, down days in danger. Body from open→close, wick from low→high. ### type: stream {#chart-stream} Centered stacked area. Each layer is centred on the x-axis instead of stacking from the bottom. Useful for showing composition trends where the total varies; the centred shape reads as a flowing stream. ### type: bump {#chart-bump} Line chart where the Y axis is RANK instead of value. Each series gets ranked across categories; lines cross when the leaderboard reorders. 'Who was #1 each year' — popularity drift, market-share leaders, sports standings. ### type: horizon {#chart-horizon} Compressed time series. Each `series` becomes a thin lane; values fold into deeper-colored bands above the baseline so a 36 px lane can carry the same information as a 200 px line chart. Use to compare many time series stacked vertically — server load per region, latency per endpoint — where the per-series shape matters more than absolute pixel height. `bands` (default 3) controls how aggressively the fold compresses range. ## Flow / conversion {#family-flow} How a quantity moves between stages or sources. Funnel for ordered drop-off; sankey for arbitrary weighted flows between any pair of nodes. ### type: funnel {#chart-funnel} Conversion-stage drop-off. `stages[]` is an ordered list of `{label, value, color?}`. The renderer draws a tapered band between adjacent stages; the right-hand readout shows the value + percentage of the first stage. ### type: sankey {#chart-sankey} Flow between stages with curved ribbons sized by link value. `nodes[]` is `{id, label?, color?}`; `links[]` is `{source, target, value}` referencing node ids. The renderer derives the left-to-right column placement from the link graph (BFS depth), stacks nodes within each column by their incoming-or-outgoing total, and routes a cubic-Bezier ribbon between every pair. ### type: gantt {#chart-gantt} Horizontal bars on a time axis, one per task. Project schedules, release plans, roadmap windows. start / end are numeric — author picks the unit (days, weeks, hours, or Unix ms with tick_format='date'). ## Network / relationship {#family-network} Edges between nodes. Network for free-form graphs (force-relaxed layout); chord for fully-connected directional flow matrices. ### type: network {#chart-network} Node-link diagram with a small Fruchterman-Reingold-ish force relaxation (~60 iterations on each render). Best for graphs up to ~50 nodes — bigger structures need a real graph-viz library. `nodes[]` + `links[]` share the same shape as `sankey`. Node radius scales with degree; hovering a node surfaces its label + degree in the tooltip. ### type: chord {#chart-chord} Circular relationship diagram. `groups[]` defines the perimeter sequence (clockwise from 12 o'clock); `matrix` is an N×N flow matrix where `matrix[i][j]` is the flow from `groups[i]` to `groups[j]`. Each group occupies an outer arc sized by its total in+out flow; ribbons through the centre carry the pairwise flows. ### type: arc-diagram {#chart-arc-diagram} Nodes positioned evenly on a horizontal baseline; each link draws a semicircular arc above the baseline connecting its source and target. Same `nodes` + `links` payload as `network`/`sankey` — what changes is the layout. Use when the *order* of nodes carries meaning (genealogy, chronology, sentence-level word adjacency) and a force-relaxed network would obscure that order. Arc thickness scales with `links[].value`; arc color follows the source node's color token. ## Multivariate / matrix {#family-matrix} More than two dimensions per record. Heatmap for a 2-D grid coloured by value; scatter-matrix for pair-wise scatters across N variables; parallel-coordinates for per-record polylines crossing N axes. ### type: heatmap {#chart-heatmap} N×M cell grid coloured by value. `cells` is a 2D array (outer = rows, inner = columns). Optional `row_labels` / `col_labels` annotate the edges. `scale` picks the palette family: sequential (one-sided ramp on accent) or diverging (accent for positives, danger for negatives). Hover any cell for the raw value. ### type: scatter-matrix {#chart-scatter-matrix} N×N grid of mini scatter plots for multivariate correlation reading. `variables[]` defines each axis; `records[]` is a flat list of objects keyed by variable id. Domains auto-derive from the records unless declared explicitly. > [!TIP] How to read it > Diagonal cells (top-left to bottom-right) label each variable. Off-diagonal cells plot the column-variable on X against the row-variable on Y. Each cell carries an `r=` chip in its top-left — Pearson correlation between the two variables (-1 to +1). Values where `|r| ≥ 0.7` show in accent-strong: those are the strong relationships worth investigating. Hover any off-diagonal cell to see the pair, n, and r in a tooltip; click to pin. ### type: parallel-coordinates {#chart-parallel-coordinates} One vertical axis per variable; each record draws a polyline crossing all axes at its scaled position. Best for spotting multi-variable clusters (lines that bunch together) or outliers (lines that diverge). Optional `_label` and `_color` on each record tag it visually. ## Goal / progress {#family-goal} Where a value sits inside a known range (often with a target). Gauge for a single arc; bullet for actual-vs-target with zone bands; radar for multi-axis profile comparison. ### type: gauge {#chart-gauge} Semicircular arc, 0 → max, with a needle / fill at the current value and an optional target tick. Use for single-metric status (SLO budget, runway, uptime) where the gap to target is the point. Optional `zones` paint coloured threshold bands behind the value. ### type: bullet {#chart-bullet} Actual-vs-target on a banded horizontal track — Stephen Few's bullet chart. One row per `tracks[]` entry: `label`, `value` (current), `target` (optional vertical tick), `max` (right-edge), optional `zones` painted behind the value. ### type: radar {#chart-radar} N spokes radiating from centre, one filled polygon per series. Best for 3–8 axes and 1–4 series. `axes[].label` names the spoke; optional `axes[].max` overrides per-axis scaling. `series[].values` array must align with `axes` by index. ## Tile cartograms {#family-geo} Value per region laid out on a coarse world tile grid. NOT a real map — country outlines are not drawn — but the visual rhythm is enough for at-a-glance regional comparisons. The honest name is `tile-map`; `geo` stays as an alias. ### type: tile-map (alias: geo) {#chart-geo} Tile cartogram. `regions[]` is a list of `{id, value, label?}` where `id` is an ISO 3166-1 Alpha-2 country code (US, GB, DE, BR, ...) or the synthetic `OTH` bucket. The kit ships a fixed tile grid (~60 cells) that approximates a flat world; absent regions render as faint placeholder outlines so the layout reads. Cell fill scales with value in a single-hue sequential ramp. This is intentionally NOT a choropleth — no country outlines, no topojson dependency. ## Small multiples {#family-small-multiples} One chart shape repeated across N panels on a shared scale. The panels answer a question a single combined chart cannot: *which of these is different, and in what way* — four lines in one axis frame is a tangle, four frames side by side is a comparison. ### chart-grid {#chart-grid} `panels[]` holds one payload per panel — the same fields the child chart would take, minus its `type`, which `child_type` sets once for the grid. `cols` fixes the column count; panels wrap. Every panel is drawn on the same y-scale, which is the whole point: a panel that looks flat IS flat relative to its neighbours. Read left to right: eu-west rising, us-east falling, ap-south compounding, sa-east unchanged. On one axis those four series would cross each other eleven times.