import { EventDropChart } from "semiotic/physics"
Example
Each circle is one event. Its event time selects a window; its arrival time determines when that window's admission policy is checked. This history accepts six events and rejects the old event arriving at 33. Advancing the watermark closes windows without relabeling events they already accepted.
Replay and recorded admission
With watermark={{ delay: 8 }}, arrivals advance the watermark from the greatest event time seen so far. The comparison uses the end of the event's window, including equality. timeScale changes playback speed while preserving those decisions.
Use watermark.value to test a fixed current policy. If your records include the watermark at each original arrival, pass that field through watermarkAtArrivalAccessor; current window closure can then change independently of historical acceptance. TheWatermarks example demonstrates this with an inspectable decision for each event.
Read the containers and the clock
A closed lid is solid for every event. In a snapshot of the current board, previously accepted events start beneath their lids. Later arrivals fall onto the ramp and roll into the farthest-left bin. Window labels report accepted source totals; the far-left label reports the total sent there. These totals describe the snapshot, including events still being illustrated. If you rewind current closure while retaining recorded rejections, that rejected history starts inside the far-left bin; the reopened board cannot reenact its earlier rejection.
To show the causal sequence, supply successive data and watermark states: let an event enter, close its lid, then supply the late arrival. Keep the chart mounted and use stable event IDs. Thethree-step Watermarks lesson pauses source time while each arrival travels and counts actual container occupancy. Changing timeScale alone does not animate historical lid changes.
For live container counts, use the metadata frombuildEventDropPhysics with the same layout options as the chart. The helper classifies each body's center by its physical container, independently of its source admission flag. A body inside a bin can still be moving; this is occupancy, not a claim that it has settled.
TSX
import { readEventDropOccupancy } from "semiotic/physics" // In frameProps.onTick, using metadata from the matching layout: const counts = readEventDropOccupancy(metadata, controls.readBodies()) // { accepted: [countPerWindow, ...], late, inFlight, total } // sum(accepted) + late + inFlight === total // total covers materialized bodies; queued arrivals are not included.
Travel from source to board
Try the single-emitter playgroundto pause a journey, turn the source on and off, and send an older event toward a closed window.
Set arrival={ mode: "travel", durationMs: 800, path: "connector" }to move events from their source tiles before releasing them to gravity. Arrival times still mean board entry. Finite replay starts early enough to show the first journey; timeScale speeds up both travel and arrival pacing. Choose durationMs (milliseconds in either timeUnit) or speedPxPerSec, a speed ceiling that derives one shared duration from the longest path. A constant duration preserves arrival ties across sources.
TSX
<EventDropChart data={[ { id: "newer", source: "p1", time: 35, arrivalTime: 0 }, { id: "older", source: "p2", time: 5, arrivalTime: 0.25 } ]} sources={[{ id: "p1", label: "P1" }, { id: "p2", label: "P2" }]} sourceRail={{ side: "top" }} arrival={{ mode: "travel", durationMs: 2000, path: "straight" }} timeUnit="s" windows={{ size: 10 }} watermark={{ delay: 100 }} title="Out-of-order events" description="P2 emits later and travels toward an older event-time window." />
React paths may be callbacks returning finite points, including the supplied source and destination endpoints. The compiled path runs in the built-in kernel on both sync and worker execution. Travelling bodies ignore contacts and sensors and count as inFlight. Their tooltip/style datum carries __phase: travel, board, late, or settled. Reduced motion and server rendering show the same settled board as drop mode. Replay projection totals still describe all supplied rows, regardless of animation progress.
Historical admissions already beneath closed lids, or recorded rejections whose lids have reopened, appear directly in their containers. Rows without a visible source tile use ordinary drops. A resize preserves elapsed travel; admitted bodies stay on the board. Imperative pushes begin their journey immediately; scheduling an unbounded stream remains application-owned.
Sources and admission accounting
Source tiles are keyboard accessible and can use circle, square, triangle, hexagon, or a GlyphDef pictogram. Their active state is controlled by your application; update it in onSourceClick and use it when scheduling arrivals. Hiding a tile removes its table column without deleting its historical totals.
TSX
import { EventDropChart, syntheticArrivals } from "semiotic/physics" const stream = syntheticArrivals([ { id: "p1", interval: 500 }, { id: "p2", interval: 300, jitter: "watermarks" }, { id: "p3", interval: 2000, jitter: "watermarks", burst: { min: 5, max: 15, gapMs: [1500, 2500], intraMs: 20 } } ], 42) const events = Array.from({ length: 60 }, () => stream.next().value!) <EventDropChart data={events} timeAccessor="eventTime" timeUnit="ms" windows={{ size: 2500 }} watermark={{ delay: 1000 }} sources={[ { id: "p1", label: "P1", mark: "circle" }, { id: "p2", label: "P2", mark: "square" }, { id: "p3", label: "P3", mark: "triangle" } ]} colorBy={{ window: "cycle" }} title="Three producers" description="Arrival-ordered events grouped into 2.5-second windows." />
The EventDropChartHandle ref exposes getLedger(), getSourceStats(id), getWatermark(), getClock(), setTimeScale(k), and getStore(). Ledger rows contain windowId, start, end, accepted, late, bySource, open, closedAt and watermarkAtClose. These are source snapshot totals, independent of moving body positions. A close observation captures counts at closure; later rejected arrivals can increase the ledger's late total.
For application-owned clocks, createSyntheticEmitter(spec, seed).advance(deltaMs, options) accepts simulated milliseconds and optional paused, rate, and active source flags. Pausing advances neither its time nor its sequence. The pure EventDropLedger accumulator accepts arrivals in nondecreasing arrival order; advance(now) evaluates external watermarks and source idle timeouts. Its watermark policy also supports perSource, idleTimeout and allowedLateness. Replay charts evaluate those policies at arrival checkpoints.
Continuous streams
Enable live for incremental admission and a moving board. Events enter the ledger when their source-to-board journey finishes. Old bodies and window colliders retire as the camera advances; historical counts stay in getLedger() and the accessible table. Omit data to accept ref pushes or built-in emitters.
TSX
import { useRef } from "react" import { EventDropChart } from "semiotic/physics" import type { EventDropChartHandle } from "semiotic/physics" function LiveStream() { const chart = useRef<EventDropChartHandle>(null) return <EventDropChart ref={chart} live={{ follow: "now", horizon: 5, retain: 15 }} emitters={{ sources: [{ id: "p1", ratePerSec: 3 }], seed: 42 }} sources={[{ id: "p1", label: "Producer", color: "#2563eb" }]} arrival={{ mode: "travel", path: "connector", durationMs: 700 }} windows={{ size: 2.5 }} watermark={{ delay: 1 }} timeUnit="s" frameProps={{ simulationExecution: "worker", config: { bodyLimit: 160 } }} title="A continuous event stream" description="Events travel into time windows; old bodies retire and counts remain." accessibleTable /> }
live=true follows the watermark with a one-window horizon and eight windows of retained history. Explicit timeExtent[0]supplies a timestamp origin. Live mode defaults to seconds; emitter intervals, jitter and duration limits always use milliseconds.timeScale scales the shared live clock. Pause freezes travel, sources, watermark polling and the camera together.
Source active flags gate built-in emitters; an explicitemitters.active entry takes precedence. Rate, source activity, speed, watermark policy and size can update during a run. Source schedules, seed and limits belong to the run. Changing window size, units or timestamp origin requires a new React key; reflow is not implemented. Supplied data arrays remain authoritative, and imperative corrections to live admissions require clearing and replaying the run.
chart.current.snapshot() captures bodies, pending travel, historical counts, clock and built-in emitter progress.chart.current.restore(saved) restores that state, including random generators and pause state. Structured-cloneable configurations work in workers; callback jitter, watermark or travel paths select sync. The playground includes snapshot controls, a three-source comparison and reduced-motion batches.
Live mode bounds bodies and colliders, not the historical ledger, which keeps one row per observed window. Serialized server/MCP rendering requires finite replay data and rejects live programs. React SSR draws the initial live board without advancing its producers. Export a saved store throughunstable_renderPhysicsSettledSVG(store, { maxSteps: 0 })from semiotic/experimental to preserve the current camera and body positions.
Clock-driven emitters
useEmitters(ref, specs, options) connects a synthetic source to a push-mode chart. Spread its frameProps onto the chart and omit data. It uses simulated time, keeps an empty frame running, and stops emission while the chart is paused or hidden. See theinteractive emitter playgroundfor regular, jittered and bursty producers with live rate and speed controls.
TSX
import { useRef } from "react" import { EventDropChart, useEmitters } from "semiotic/physics" import type { EventDropChartHandle } from "semiotic/physics" function Producer({ active = true, rate = 1, paused = false }) { const ref = useRef<EventDropChartHandle>(null) const emitters = useEmitters(ref, [{ id: "p1", ratePerSec: 2 }], { seed: 42, durationMs: 24000, maxEvents: 96, rate, active: { p1: active }, mapArrival: (event) => ({ ...event, time: event.eventTime }) }) return <EventDropChart ref={ref} timeUnit="ms" timeExtent={[0, 24000]} windows={{ size: 5000 }} watermark={{ delay: 3000 }} sources={[{ id: "p1", label: "Producer", active }]} paused={paused} frameProps={emitters.frameProps} title="A bounded event stream" /> }
Specs, seed, duration and maximum event count are captured on mount; remount the producer for a new run. Rate and active flags update without restarting ids or the remaining interval. A source switched off does not catch up when enabled again. Limits bound total generated events, not retained chart memory. The pure createSyntheticEmitter accepts the same limits as its third argument.
The hook uses synchronous onTick. Pass an observer through its options.onTick to run after emission. For reduced-motion controls, set manual: true and call advance(deltaMs) explicitly. Use the chart handle's setTimeScale to change simulation speed; EventDrop's timeScale prop controls recorded replay pacing. This hook keeps its emitter outside the frame. Save and restore itssnapshot() alongside the frame snapshot to rewind both; restoring only the frame rebases the hook clock and keeps its sequence. The pure emitter exposes the same snapshot/restore methods.
With arrival choreography, history: "present" is the default: accepted history beneath closed lids and recorded rejections belonging to currently open windows appear directly in their containers. The playground uses arrival={ mode: 'travel', history: 'travel', durationMs: 1200 }so every emitted row makes the full journey. Its admission reservations assume equal travel durations and an unchanged watermark policy. Uselive with built-in emitters for admission at the actual handoff, including worker execution.
Physics theme tokens
Every PhysicsCanvasTheme key accepts a dedicated CSS custom property named --semiotic-physics-KEY, with the exact camelCase key. The keys are annotationBackground, annotationStroke, annotationText, background, border, closedWindowFill, closedWindowStroke, danger, focus, grid, gutterFill, lateFill, openWindowFill, openWindowStroke, primary, selectedFill, selectedStroke, success, text, textSecondary, and warning. Dedicated tokens precede existing Semiotic and documentation-site tokens. React callers can use frameProps={{ theme: { background: "#102030", openWindowFill: "#204060" } }}. The same frameProps theme is retained by serialized server rendering.
Body marks and glyphs affect paint only: their colliders stay circular. Both settled SVG and animated exports preserve the built-in marks. diagnoseConfig warns when a declarative glyph's aspect ratio exceeds 1.5.
Props
| Prop | Type | Required | Default | Description |
|---|
live | boolean | object | — | false | React continuous mode: true or { follow: "watermark" | "now", horizon, retain }. Times use timeUnit, which defaults to seconds in live mode. Retires old bodies while preserving historical counts. |
emitters | object | — | — | Fixed-step producers in live push mode: { sources, seed?, rate?, active?, paused?, durationMs?, maxEvents? }. Omit data. Supports sync and worker execution and frame snapshots. |
arrival | string | object | — | "drop" | Source choreography: "drop" or { mode: "travel", durationMs?: 800, speedPxPerSec?, path?: "straight" | "connector" | callback, history?: "present" | "travel" }. History defaults to present; travel animates every row. Choose duration or speed. Requires a visible source and the built-in engine. |
sources | array | — | — | Source identities with id, label, color, mark, glyph, active and visible. Historical counts remain when a tile is hidden. |
sourceAccessor | string | function | — | "source" | Field identifying an event's source. |
sourceRail | object | — | — | { side: left | right | top | none, tileSize? }. Use top for a narrow board. right keeps the late gutter on the left. |
onSourceClick | function | — | — | Called with the source on click, Enter or Space; the host updates active state. |
timeUnit | "ms" | "s" | — | — | Explicit arrival-time units. Omitted infers ms above an absolute timestamp of 100000; use explicit units for stable streaming behavior. |
onLedgerChange | function | — | — | Receives admission ledger rows, on lifecycle transitions or at most every 500ms during accumulation. |
onWatermarkChange | function | — | — | Receives (value, previous) on watermark advances. |
onClockTick | function | — | — | Simulation clock HUD callback, at most 10Hz, in sync and worker execution. |
clockTickMs | number | — | 100 | Minimum milliseconds between clock HUD callbacks; minimum 100. |
windowChrome | object | — | — | { show?, fill? }. Hide window paint without removing colliders, or supply a color / ledger-row fill callback. |
data | array | Yes | — | Event rows with event and arrival times. |
timeAccessor | string | function | — | "time" | Event-time field used for windows. |
arrivalAccessor | string | function | — | "arrivalTime" | Arrival-time field used for admission order and ingestion pacing. Ties retain source order. |
watermarkAtArrivalAccessor | string | function | — | — | Recorded watermark for each arrival, independent of current window closure. |
windows | object | — | { size: 10 } | Window config such as { size, gapPolicy }. |
watermark | object | function | — | — | { delay } or a latest-event-time function replays a monotonic watermark; { value } tests one fixed admission policy. |
timeScale | number | — | 1 | Arrival replay playback speed; higher is faster (1 = real event-time). |
ballRadius | number | — | 7 | Radius for each simulated event body. |
colorBy | string | function | object | — | — | Categorical field, or { window: cycle | string[] } for a cyclic window palette. |
seed | number | — | 1 | Deterministic simulation seed. |
showProjection | boolean | — | true | Draw the window bins, watermark, closed windows, and late-event scaffold over the moving bodies. |
size | array | — | [760, 360] | [width, height] in pixels. |
width | number | — | 760 | Width alias used when size is omitted. |
height | number | — | 360 | Height alias used when size is omitted. |
hoverRadius | number | — | 16 | Pixel hit radius for event-body hover tooltips. |
paused | boolean | — | false | Pause the simulation. |
tooltip | boolean | function | object | — | true | Enable the default event-body tooltip, pass a custom tooltip renderer/config, or set false to hide tooltips while hover observations continue. |
frameProps | object | — | — | Advanced StreamPhysicsFrame props. |