Skip to content

Overlays and cursors

Overlays annotate signal data without becoming sampled traces. They are owned by the application and replaced through public APIs.

Scatter series and regions

Points belong to named scatter series. Visibility is controlled per series, while hit testing and selection use each point's stable ID:

viewer.setOverlays({
  scatterSeries: [{
    id: 'peaks',
    label: 'Detected peaks',
    color: '#22d3ee',
    points: peaks.map((peak) => ({
      id: peak.id,
      x: peak.time,
      y: peak.value,
      kind: 'peak',
      metadata: { index: peak.index },
    })),
  }],
  regions: [{
    id: 'stimulus-1',
    xStart: 1.0,
    xStop: 1.5,
    kind: 'stimulus',
    label: 'Stimulus',
  }],
  selectedPointId: null,
})

Regions render behind the traces and are not selectable. overlay-select emits a point ID or null. The application uses that stable identity to link selection with tables or other viewers.

setScatterSeries() replaces point series while preserving regions. addScatterSeries() and updateScatterSeries() provide stable-ID updates.

Time-interval events (viewer.events)

Events are a parallel API for selectable full-height time bands { id, x0, x1, kind? }. They are independent of scatter points and of non-selectable regions. The library does not define kind names; hosts pass opaque strings and optional kind→style maps.

viewer.events.setKindStyles({
  user: { fill: 'rgba(34, 197, 94, 0.18)', stroke: 'rgba(34, 197, 94, 0.65)' },
})
viewer.events.setEvents([
  { id: 'e1', x0: 1.0, x1: 1.5, kind: 'user' },
  { id: 'e2', x0: 2.0, x1: 2.4, kind: 'detected' },
])
viewer.events.selectEvent('e1') // silent; does not emit
viewer.events.setVisible(true)
viewer.events.clearEvents()
Method Role
setEvents Replace the overlay snapshot (fail-fast on bad/duplicate ids)
clearEvents Clear list + selection; keeps kind styles
selectEvent(id \| null) Programmatic highlight; does not emit
setVisible Show/hide all bands; retains selection while hidden
setKindStyles / getKindStyles / clearKindStyles Caller-owned kind→paint map

User clicks emit event-select (string | null). Programmatic selectEvent never emits (same idea as measurement cursors).

Event bands draw in front of traces and behind scatter points and measurement cursors. Non-selectable regions still draw behind traces.

Click precedence: scatter points first, then event bands, then empty. Point and event selection state are independent. An empty click clears both (events emit null only when selection actually changes).

setSource / setTraces clear the event list and selection but keep kind styles. Hosts call setEvents again after load. No create/edit/delete UI in this API surface.

Measurement cursors

A/B are vertical cursors in calibrated X units. C/D are horizontal cursors in left-axis units. Programmatic cursor methods do not emit user events:

viewer.setCursor('a', 1.25)
viewer.setCursorVisible('b', true)
const cursors = viewer.getCursors()

The first time a cursor pair is enabled in the options panel, it is placed at 25% and 75% of the visible range. Hiding a cursor preserves its value.

A completed user drag emits cursor-change with changedId, defensive copies of all four cursors, deltaX (B - A), and deltaY (D - C). A delta is null unless both cursors in its pair are visible and positioned.