Playback
A slider with play, pause and reset buttons that moves its value over time, read by name.
Static preview; loading the interactive plot
<script>
import { Filter, InputContext, Playback, Plot, Points, col, input, less_equal } from "hmplot";
const data = { x: [1, 2, 3, 4], y: [3, 1, 4, 2] };
</script>
<!-- Play shows the points up to x = until, one more each second. -->
<InputContext>
<Playback name="until" min={1} max={4} step={1} />
<Plot {data} height={300} axes2d x={{ domain: [0, 5] }} y={{ domain: [0, 5] }}>
<Filter where={less_equal(col("x"), input("until"))}>
<Points x="x" y="y" />
</Filter>
</Plot>
</InputContext>
Usage
An input sends its value up to the nearest input context (an InputContext, a Python Scene, or a Template instance), and everything in that context reads it by name: input("name") in JavaScript, hm.input.name in Python, or the string "$name" where a string names a column. A read is replaced by the value before its reader sees it, so moving an input re-runs its readers once, and the change animates like any other data change. Inputs go beside Plots (in a Row or Column), not inside them.