Skip to content

Geoms

A geom is a factory geom(channels, options?) that returns a Geom<T>. Add geoms with .layer(...); multiple layers stack in declaration order. Every channel is an Aes<T, V> — a column name, an accessor, or a constant.

All geoms below are exported from insomni-plot:

aggregate, area, band, bar, boxplot, connectedScatter, histogram, interval, line, point, ribbon, ridgeline, rug, rule, smooth, statRolling, text, tile, violin.

Scatter / bubble marks. x and y are required.

ChannelTypeRequired
x, ynumber | Dateyes
colorany (categorical or continuous)no
sizenumberno
shapecategorical → shape paletteno
alphanumberno
borderStylecategorical → solid | open | dashed | dottedno
overlayGlyphcategorical → secondary glyphno
overlayScalenumberno

Options include fill, radius, stroke, strokeWidth, shape (PointShapeKind), borderStyle, overlayGlyph, overlayScale, label.

import { plot, point } from "insomni-plot";
plot<Row>({ data }).layer(
point({ x: "weight", y: "mpg", color: "origin", size: "hp" }, { radius: 3 }),
);

Connected polyline. A color channel splits the data into one stroke per category; order controls vertex order.

ChannelTypeRequired
x, ynumber | Dateyes
colorcategoricalno
ordernumber | Dateno

Options: stroke, strokeWidth, curve (LineCurve), curveSamples, dashPattern, dashStyle (dashed \| dotted), nearestX, label.

import { line } from "insomni-plot";
plot<Row>({ data }).layer(
line({ x: "date", y: "price", color: "ticker" }, { curve: "monotone-x" }),
);

A line ordered by a third variable, optionally topped with points. Returns the composed line + point geoms.

ChannelTypeRequired
x, ynumber | Dateyes
ordernumber | Dateyes
colorcategoricalno
size, alphanumberno
shapecategoricalno

Options: line (LineOptions), point (PointOptions or false for a bare path).

Filled area from a baseline. A single y column draws 0 → y; an array of column keys draws a stacked area keyed by column name.

ChannelTypeRequired
xnumber | Dateyes
ynumber | Date or (keyof T)[]yes
colorcategoricalno

Options: fill, stroke, strokeWidth, position ("identity" / "stack" / "fill"), order (StackOrder), nearestX, label.

import { area } from "insomni-plot";
plot<Row>({ data }).layer(area({ x: "date", y: ["us", "eu", "asia"] }, { position: "stack" }));

Categorical bars. A single y column draws one bar per category; an array of column keys draws multi-series bars (position: stack / dodge / fill / identity). Orientation is auto-detected from scale types (band axis = category axis) and can be forced with orientation.

ChannelTypeRequired
xstring | number | Dateyes
ystring | number | Date or (keyof T)[]yes
colorcategoricalno

Options: orientation, fill, stroke, strokeWidth, cornerRadius, borderStyle, position (BarPosition), order, groupPadding, showTotals, showValues, labelColor, labelFontSize, label.

import { bar } from "insomni-plot";
plot<Row>({ data }).layer(
bar({ x: "quarter", y: ["q1", "q2", "q3", "q4"] }, { position: "dodge" }),
);

Bins one numeric variable. Provide exactly one of x (vertical bars) or y. A color channel splits the sample into per-group bins.

ChannelTypeRequired
x or ynumberone of
colorcategoricalno

Bin selection (in priority order): breaksbinwidthbinsrule (sturges / rice / scott / fd). Other options: domain, nice, closed, y measure (count / frequency / density / proportion), position, mirror, fillAlpha, fill, stroke, strokeWidth, cornerRadius, gap, groupPadding, showCounts.

import { histogram } from "insomni-plot";
plot<Row>({ data }).layer(histogram({ x: "weight" }, { rule: "fd", y: "density" }));

A regression fit with an optional confidence ribbon. One curve per color group.

ChannelTypeRequired
xnumber | Dateyes
ynumberyes
colorcategoricalno

Options: method (SmoothMethod"lm" default, "poly", "loess"), degree, span, ci (true = 95%, a number for another level, false for none), samples, stroke, strokeWidth, ribbonFill, ribbonOpacity, label, nearestX.

import { point, smooth } from "insomni-plot";
plot<Row>({ data })
.layer(point({ x: "weight", y: "mpg" }))
.layer(smooth({ x: "weight", y: "mpg" }, { method: "loess", span: 0.6 }));

A rolling-window statistic (moving average and friends) drawn as a line.

ChannelTypeRequired
xnumber | Dateyes
ynumberyes
colorcategoricalno

Options: window (RollingWindow — required), statistic (default "mean"), axis, filter, curve, stroke, strokeWidth, dashStyle, nearestX, label.

A filled band between two y-bounds at each x.

ChannelTypeRequired
xnumber | Dateyes
y0, y1number | Dateyes

Options: fill, stroke (both accept a Color or a theme accent key), strokeWidth, fillAlpha, label.

Error bars / range marks. Bind either (yMin, yMax) for vertical intervals (then x is required) or (xMin, xMax) for horizontal (then y is required) — not both.

ChannelTypeRequired
xnumber | Datewhen yMin/yMax set
ynumber | Datewhen xMin/xMax set
yMin, yMaxnumber | Datevertical pair
xMin, xMaxnumber | Datehorizontal pair
colorcategoricalno

Options: stroke (Color or accent key), strokeWidth, caps, capWidth, label.

A static reference band spanning an x- or y-range. Channels take a [start, end] tuple, not a data column.

ChannelTypeRequired
x[number | Date, number | Date]one of
y[number | Date, number | Date]one of

Options: fill / stroke (Color or accent key), strokeWidth, alpha, label, labelColor.

A reference line at a constant value. x draws a vertical line; y a horizontal one.

ChannelTypeRequired
x or ynumber | Dateone of

Options: stroke (Color or accent key — positive / negative / warn / info), strokeWidth, dashPattern, label, labelColor, labelInset.

Marginal tick marks along the axes. side defaults to whichever channels are wired.

ChannelTypeRequired
xnumber | Dateno
ynumber | Dateno
colorcategoricalno

Options: side ("x" / "y" / "both"), length, strokeWidth, stroke, opacity, label.

Per-row text labels.

ChannelTypeRequired
x, ynumber | Date | stringyes
textstringyes

Options: fontSize, color, align, offsetX, offsetY, box (rounded-rect background), collisionMode ("none" / "hide" / "stagger"), collisionPadding, label.

Heatmap cells. fill is typically a numeric column driving the color scale (the legend renders as a continuous color bar); omit it and pass options.fill for a constant.

ChannelTypeRequired
x, ystring | number | Dateyes
fillany (continuous)no

Options: fill, padding / paddingX / paddingY, stroke, strokeWidth, cornerRadius, showValues, labelColor, labelFontSize, minLabelCellPx, cellWidth, cellHeight, na, label.

Box-and-whisker summary per category. The band axis is the category; the other is the distribution. A color channel dodges side-by-side within each band.

ChannelTypeRequired
xstring | number | Dateyes
ystring | number | Dateyes
colorcategoricalno

Options include orientation, width, varwidth, whisker (WhiskerRule), quantile (QuantileMethod), notched, notchWidth, points (PointsMode"auto" / "always" / "none"), pointsThreshold, pointJitter, outliers, fill, fillAlpha, stroke, strokeWidth.

KDE density per category, optionally with an inner annotation.

ChannelTypeRequired
xstring | number | Dateyes
ystring | number | Dateyes
colorcategoricalno

Options include orientation, width, bandwidth (KdeBandwidth), gridSize, kernel (KdeKernel), trim, scale ("width" / "area" / "count"), inner ("none" / "box" / "quartile" / "stick"), points, fill, stroke, showCounts.

Stacked, overlapping density ridges — one row per category. Provide a numeric value on x or y; the other axis carries the row category.

ChannelTypeRequired
x, ystring | numberyes (one numeric, one category)
colorcategoricalno

Options include orientation, geom ("kde" / "histogram"), overlap, scale, KDE/histogram pass-throughs, fillMode ("solid" / "gradient"), gradient, inner, baseline.

Bins along an axis and reduces each bin to a summary, rendering an inner geom. Falls back to the raw geom when bins are too sparse (dissolveAt).

ChannelTypeRequired
x, ynumber | Dateyes

Options: binBy, binSize ("auto" default), summary (scalar like "mean" / "median", or a bundle like "mean+ci" / "median+iqr"), filter, dissolveAt, geom ("point" / "line" / "bar" / "interval" / "ribbon"), fill, stroke, radius, curve, ciLevel, caps, capWidth, fillAlpha, label.

import { aggregate } from "insomni-plot";
plot<Row>({ data }).layer(
aggregate(
{ x: "timestamp", y: "latency" },
{
summary: "mean+ci",
geom: "ribbon",
},
),
);