Skip to main content

entity.label#

Create or update a keyed text label at a data coordinate.

SYNTAX#

function entity.label(props: { key: string; x: number; y: number; text: string; color: string; bg?: string; align?: 'left' | 'center' | 'right'; forceOverlay?: boolean }): EntityHandle

ARGUMENTS#

  • props ({ key, x, y, text, color, bg?, align?, forceOverlay? }) — x is a unix-second timestamp; y is a price. text is the displayed string. align defaults to center.

RETURNS#

EntityHandle — { set(props), delete() }.

REMARKS#

Label rendering ships in Round 2 Track F; entities are accepted by the runtime but render as no-ops until then. Font size, family, and weight are fixed in v1 — only color, bg, and align are stylable. For sized text, use a screen-space table instead (RuntimeTableCell.textSize).

EXAMPLE#

function onBar(i, ctx) {
  if (!ctx.isLast) return;
  entity.label({
    key: 'last-price',
    x: candles[i].time,
    y: candles[i].close,
    text: 'Last: ' + candles[i].close.toFixed(2),
    color: '#ffffff', bg: '#26a69a', align: 'left'
  });
}

SEE ALSO#

indicator.entity.line, indicator.entity.marker, types.EntityHandle, types.RuntimeTableCell