Skip to content

DOM adapter

ChartDOMAdapter is the non-canvas UI seam. The chart renders market data, axes, grid, and crosshair labels on canvas; the adapter owns overlay UI such as the indicator-label region, indicator actions, and pane dividers.

Import DefaultDOMAdapter from the root entry and adapter authoring contracts from @ardinsys/financial-charts/extensions:

ts
import { DefaultDOMAdapter } from "@ardinsys/financial-charts";
import type {
  ChartDOMAdapter,
  IndicatorLabelModel,
  PaneDividerModel,
} from "@ardinsys/financial-charts/extensions";

ChartDOMAdapter

ts
interface ChartDOMAdapter {
  createOverlay(
    host: HTMLElement,
    context: ChartDOMOverlayContext
  ): ChartDOMOverlay;

  createIndicatorLabel(
    model: IndicatorLabelModel,
    actions: IndicatorLabelActions
  ): IndicatorLabelHandle;

  createPaneDivider?(
    model: PaneDividerModel,
    actions: PaneDividerActions
  ): PaneDividerHandle;
}

Use DefaultDOMAdapter when CSS hooks are enough. Pass a custom adapter in ChartOptions.domAdapter when your app should render labels or pane dividers through its own DOM primitives.

Adapter models are borrowed readonly declarative inputs. Render the complete current state on every update() rather than diffing against chart internals. Geometry fields are logical CSS pixels.

Overlay

createOverlay(host, context) is called once during chart construction.

ValueDescription
hostCore-owned chart host that also contains canvases.
context.themeKeyActive theme key.
context.labelTopOffsetTop offset for the indicator label region.
indicatorLabelContainerElement where the chart appends indicator label roots.
update(context)Repositions or rethemes overlay DOM.
destroy()Removes overlay DOM and listeners.

The adapter mounts the overlay into host. The chart calls update() after theme or layout changes and calls destroy() once during chart disposal.

Indicator labels

IndicatorLabelModel is declarative label state:

FieldDescription
instanceIdUnique identity of this configured indicator instance.
typeIdStable factory/type identifier shared by same-type instances.
labelKeyStable application-facing identifier for the label kind.
themeKeyActive theme key.
nameLocalized display name.
detailOptional parameter/source text such as 20 close.
segmentsCurrent value segments, each with text and optional color.
visibleCurrent indicator visibility.
actionsWhich controls should render.
actionTitlesLocalized action labels/tooltips.

The adapter returns a handle:

MethodDescription
rootElement the chart mounts into the label region or pane.
update(model)Re-render from new label state.
destroy()Remove listeners and adapter-owned resources.

The chart mounts root; the adapter must not append it itself. It may replace the root's children during update(), but the root identity must remain stable. The chart calls destroy() before removing the root.

Action callbacks keep behavior in the chart core: onToggleVisibility(visible), onOpenSettings(), and onRemove(). The visibility argument is the requested resulting state: the show action passes true, and the hide action passes false. DefaultDOMAdapter uses matching show/hide classes, titles, ARIA labels, and callback values.

Pane dividers

createPaneDivider(model, actions) renders the draggable hit area between panes. The method is optional; if a custom adapter omits it, the chart uses the default divider.

Model fieldDescription
keyStable divider key.
themeKeyActive theme key.
beforePaneId / afterPaneIdAdjacent pane ids.
x, y, width, heightLogical pixel bounds for the hit area.

Call actions.onPointerDown(event) from the divider's pointer-down handler to let the chart run pane resizing.

The chart mounts the returned root, calls update() as panes move or themes change, and calls destroy() when the divider disappears or the chart is disposed. If createPaneDivider() is omitted, only the divider falls back to DefaultDOMAdapter; custom overlay and label methods remain active.

Default DOM hooks

DefaultDOMAdapter exposes stable CSS and data hooks for restyling:

  • Overlay: .fci-overlay, .fci-indicator-labels, data-id="indicator-labels".
  • Label root: .financial-indicator, .fci-indicator, data-id="indicator-label", data-indicator-instance-id, data-indicator-type, and data-indicator-label-key.
  • Label parts: .fci-wrapper, .fci-label, .fci-name, .fci-extra, .fci-value, .fci-value-segment.
  • Actions: .fci-actions, .fci-btn, .fci-action, .fci-action-show, .fci-action-hide, .fci-action-settings, .fci-action-remove.
  • States: .fci-hide, .fci-hidden.
  • Pane dividers: .fci-pane-divider, .fci-pane-divider-line, data-id="pane-divider".

See Design-system adapter for a complete custom adapter example.

Released under the Apache 2.0 License.