HMPlot

Mapping

Channels (x, y, fill, size, ...) that the marks inside it share.

Line chart of y against x, with scatter plot of y against x. x from 0.9 to 4.1, y from 0.9 to 4.1. 4 rows.

Static preview; loading the interactive plot

<script>
  import { Line, Mapping, Plot, Points } from "hmplot";
  const data = { x: [1, 2, 3, 4], y: [3, 1, 4, 2] };
</script>

<Plot {data} height={300} axes2d>
  <Mapping x="x" y="y">
    <Line />
    <Points />
  </Mapping>
</Plot>

Options

Position

xchannel
The x position: a column, per-row values, or one value.
ychannel
The y position: a column, per-row values, or one value.
zchannel
The z position, in a 3D plot: a column, per-row values, or one value.
positionchannel
Positions as one column or an N x 2 (or N x 3) array, instead of x, y and z.

Appearance

fillchannel
The fill color: a CSS color, or a column of numbers or categories mapped to colors.
colorchannel
The line or text color: a CSS color, or a column mapped to colors.
sizechannel
The size of each point or label: a number, or a column mapped to sizes. In px.
widthchannel
The line width: a number, or a column mapped to widths. In px.
opacitychannel
The opacity, 0 to 1: a number, or a column (categories map through opacityScale). Default: 1.
outlineColorchannel
The outline's color: a CSS color, or a column of categories mapped through outlineColorScale.
outlineOpacitychannel
Border opacity from 0 to 1: a number, numeric column, array or expression. Fades the border over the fill; mark opacity still applies to both. Missing values hide the border. Default: 1.
outlineWidthchannel
The outline's width in CSS pixels, drawn inside the mark's edge (a point's at most its radius). Default: 0.

Scales

fillScalescale
The fill's scale, which marks can share: continuous({domain, colormap, transform}) for numbers, categorical({domain, range}) or ordinal() for categories.
colorScalescale
A scale for color that marks can share.
sizeScalescale
The size's scale, which marks can share: continuous({domain, range, transform}) for numbers (without a range, the automatic one), or categories with a numeric range.
widthScalescale
A scale for width that marks can share, as sizeScale.

Display

visibleboolean
Whether the mark is drawn. Default: true.
glownumber
How much the mark glows: its own color times glow blooms around it in the plot's presentation (0 does not glow); the Plot's bloom effect sets the bloom's strength and radius. SVG and PDF exports draw the whole plot as an image. Default: 0.
namestring
The Mapping's name in the settings pane; the marks inside do not take it.

Interaction

selectboolean | selection | object
Click to replace the selection; an exact repeat clears it. Shift/Meta/Ctrl-click toggles membership (whole series for Line, Area): true uses its data's selection, or give a selection(). input("root").set("id") writes an input instead: a click sets it to the clicked row's id (a drill-down's root), .set(literal(v)) to a constant, .reset() to its default, and a click on nothing restores its default (input("root", {default}), else a Select of that name's, else null); several marks may write one input.
hoverboolean | selection | object
Mark the row under the pointer as @hovered (a whole series for Line, Area), without fading the others: true uses its data's hover, or give a selection(). input("focus").set("series") writes an input instead: while the pointer is on a row the input shows its series (or .set(literal(v)), a constant), then its committed value again (a hover that would change this mark's own rows is an error).
brushboolean | selection | object
Brush rows with Shift-drag (point marks; Line, Area brush whole series): true uses its data's brush, a selection() shares one, {selection, axis} picks the axes.
respondboolean | "selected" | "brushed" | "hovered" | "nearby" | "nearest" | selection | array
Which interaction states fade this mark's other rows to selectionOpacity; "hovered" fades them while hovering, "nearest" while a row is nearest. Default: the states it sets, except hover and nearest.
selectionOpacitynumber
The opacity of the rows outside the selection while one is active. Default: 0.25.
onclick(event) => void
Called for click on this mark; row provenance is optional after transforms.
ondblclick(event) => void
Called for dblclick on this mark; row provenance is optional after transforms.
oncontextmenu(event) => void
Called for contextmenu on this mark; row provenance is optional after transforms.
onpointerenter(event) => void
Called for pointerenter on this mark; row provenance is optional after transforms.
onpointerleave(event) => void
Called for pointerleave on this mark; row provenance is optional after transforms.
onpointermove(event) => void
Called for pointermove on this mark; row provenance is optional after transforms.
onpointerdown(event) => void
Called for pointerdown on this mark; row provenance is optional after transforms.
onpointerup(event) => void
Called for pointerup on this mark; row provenance is optional after transforms.
onpointercancel(event) => void
Called for pointercancel on this mark; row provenance is optional after transforms.
onpointerover(event) => void
Called for pointerover on this mark; row provenance is optional after transforms.
onpointerout(event) => void
Called for pointerout on this mark; row provenance is optional after transforms.
onpointermissed(event) => void
Called for pointermissed on this mark; row provenance is optional after transforms.
enterEffectboolean | "fade" | object
How rows that arrive in a keyed update appear: "fade", or {effect, duration, easing}. animate()'s enter option is the value a channel starts from.
exitEffectboolean | "fade" | object
How rows that leave in a keyed update disappear, as enterEffect. animate()'s exit option is the value a channel ends at.

Animation

animationboolean
Animate changes to the mark's values. Default: false.
animationDurationnumber
How long an animated change takes. Default: 300 ms.
animationEasing"linear" | "quad-in" | "quad-out" | "quad-in-out" | "cubic-in" | "cubic-out" | "cubic-in-out" | "sine-in-out"
The animation's easing. Default: "cubic-in-out".

Series

seriescolumn | column[] | array
Split the rows into separate paths, one per value of this column (Line, Area). Without it, a Line colored or an Area filled by a category column splits by that column.

Segment ends

startchannel
Where each segment starts (Segments, Arrows): a column of positions or an N x 2 (N x 3) array.
endchannel
Where each segment ends, as start.

Symbol rotation

rotationnumber
The symbol's rotation. Default: 0 degrees.

Symbol

shapestring | column | string[]
The point symbol: a shape name, a column of categories mapped to shapes, or one name per row. Default: "circle".
shapeScalescale
A categorical() scale from the shape column's categories to shape names.

Usage

Explicit mark properties win, then nearest Mapping, outer Mapping, and defaults. Mapped field names resolve in the consuming mark’s Data scope. Event handlers, names, and structural references are not inherited.

Related examples

Shared mappings