Skip to content

Tooltip

Defined in: core/tooltip.ts:91

Floating tooltip panel rendered as plain DOM (not on the canvas). Each BaseChart owns one when showTooltip !== false and pushes structured content into it as the user hovers / focuses datums.

Typically you don’t construct this directly — BaseChart does that for you and exposes it via chart.tooltip. Custom charts that draw their own hover logic can call show or showStructured to display a panel anchored to canvas coordinates.

BaseChartConfig.tooltipContainer for portal control.

new Tooltip(canvas, theme?, mountTarget?): Tooltip

Defined in: core/tooltip.ts:111

HTMLCanvasElement

The chart’s <canvas> element. Used as the positioning anchor (canvas coords → viewport coords).

Theme | null

Optional palette to colour the panel. Pass null to use built-in fallback colours.

ParentNode

Where to append the tooltip element. Defaults to document.body for compatibility, but BaseChart resolves a smarter default (shadow root, then the chart container) so Shadow DOM and modal stacking contexts work out of the box.

Tooltip

canvas: HTMLCanvasElement

Defined in: core/tooltip.ts:95

The host canvas — used to compute viewport coords from canvas coords.


el: HTMLDivElement | null

Defined in: core/tooltip.ts:93

The live tooltip element (null in SSR / after destroy).

destroy(): void

Defined in: core/tooltip.ts:273

Tear down: detach scroll/resize listeners (window + each scrollable ancestor walked at construction) and remove the tooltip element from the DOM. After destroy, el is null and any further calls are no-ops.

void


hide(): void

Defined in: core/tooltip.ts:260

Fade and hide the tooltip. Idempotent.

void


setTheme(theme): void

Defined in: core/tooltip.ts:157

Apply a Theme to subsequent tooltip renders. Colours flow from (in priority order):

  • explicit theme.tooltipBg / .tooltipBorder / .tooltipText
  • theme.surface / .axis / .text (so built-in themes auto-coordinate)
  • hard-coded fallbacks (only when no theme is set, e.g. unit tests)

Pass null to revert to fallbacks.

Theme | null

void


show(canvasX, canvasY, text): void

Defined in: core/tooltip.ts:223

Show plain text (escaped automatically).

number

number

string

void


showStructured(canvasX, canvasY, content): void

Defined in: core/tooltip.ts:179

Render a tooltip from structured content. Safe against XSS.

number

number

TooltipContent

void