Architecture

IIFE Build and Registration

  • Built as IIFE via Vite (see vite.config.lib.ts). Entry src/index.ts, output dist/index.iife.js.

  • Registers itself with the Octopus host when the global becomes available.

  • Type declarations emitted under dist/.

Runtime Data Flow

  • Either subscribes to new values (tangoAttributes subscription) or polls HDB++ histories.

  • Applies optional server-side downsampling and client-side throttling (appendInterval).

  • Bar view (barView = true) reprojects traces into a matrix (attr × time).

Importing in octopus-frontend

  • Include dist/index.iife.js; it auto-registers under key timeline (label “Timeline”).

SDK Utilities

Chart plumbing shared with the graph widget is delegated to @ska-octopus-widget-sdk/widget-sdk:

  • canonicalAttr, parseMargins, buildAxisTitle — normalisation and formatting helpers; imported in src/utils/utils.ts and src/hooks/useTimelineLayout.ts.

  • formatLegendName, extractStationAndNumber — legend label resolution; re-exported from src/utils/utils.ts.

  • getPlotlyLegendConfig — returns Plotly legend anchor/orientation config for a named position; getLegendAndMargin in src/legendUtils.ts adds timeline-specific margin values on top.

Full SDK API reference: WIDGET_SDK.md