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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Tooltip(
canvas,theme?,mountTarget?):Tooltip
Defined in: core/tooltip.ts:111
Parameters
Section titled “Parameters”canvas
Section titled “canvas”HTMLCanvasElement
The chart’s <canvas> element. Used as the
positioning anchor (canvas coords → viewport coords).
theme?
Section titled “theme?”Theme | null
Optional palette to colour the panel. Pass null
to use built-in fallback colours.
mountTarget?
Section titled “mountTarget?”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.
Returns
Section titled “Returns”Tooltip
Properties
Section titled “Properties”canvas
Section titled “canvas”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).
Methods
Section titled “Methods”destroy()
Section titled “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.
Returns
Section titled “Returns”void
hide()
Section titled “hide()”hide():
void
Defined in: core/tooltip.ts:260
Fade and hide the tooltip. Idempotent.
Returns
Section titled “Returns”void
setTheme()
Section titled “setTheme()”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.
Parameters
Section titled “Parameters”Theme | null
Returns
Section titled “Returns”void
show()
Section titled “show()”show(
canvasX,canvasY,text):void
Defined in: core/tooltip.ts:223
Show plain text (escaped automatically).
Parameters
Section titled “Parameters”canvasX
Section titled “canvasX”number
canvasY
Section titled “canvasY”number
string
Returns
Section titled “Returns”void
showStructured()
Section titled “showStructured()”showStructured(
canvasX,canvasY,content):void
Defined in: core/tooltip.ts:179
Render a tooltip from structured content. Safe against XSS.
Parameters
Section titled “Parameters”canvasX
Section titled “canvasX”number
canvasY
Section titled “canvasY”number
content
Section titled “content”Returns
Section titled “Returns”void