Overview
TheTooltip class creates a contextual popup that displays information when hovering over chart elements. It automatically positions itself relative to a target element and includes a pointer.
Constructor
The root element of the chart
Configuration settings for the tooltip
Settings
Content Settings
Text to use for the tooltip’s label.
HTML content to use for the tooltip’s label.
Screen reader content for the label. Used with
readerAnnounce. If set, its contents will be read by screen readers when the tooltip is shown.Appearance Settings
Direction of the tooltip pointer.
vertical- Automatically points up or down based on positionhorizontal- Automatically points left or right based on positionup,down,left,right- Fixed direction
If
true, will use the same fill color for its background as its tooltipTarget.If
true, will use the same fillGradient for its background as its tooltipTarget.If
true, will use the same fill color for label text as its tooltipTarget.If
true, will use the same stroke color as its tooltipTarget.If
true, tooltip will automatically adjust text color for better visibility on its background.Position Settings
Screen coordinates the tooltip should point to. Object with
x and y properties.Screen bounds to constrain the tooltip within. Prevents tooltip from going off-screen.
Target element the tooltip is shown for.
Animation Settings
Duration in milliseconds for tooltip position changes (e.g., when jumping between targets).
Easing function for tooltip animations.
Behavior Settings
If
true, the tooltip’s target element will be considered hovered when the mouse is over the tooltip itself.If
true, the tooltip contents will be read by screen readers when displayed or changed.Properties
label
The
Label element for the tooltip (read-only).Methods
updateBackgroundColor()
Updates the tooltip’s background color based on its target element and color settings.tooltipTarget changes.
Events
Tooltip inherits allContainer events and adds visibility tracking:
visible- Fired when tooltip visibility changes
Examples
Basic Tooltip
HTML Tooltip
Tooltip with Custom Styling
Tooltip with Fixed Orientation
Animated Tooltip
Accessible Tooltip
Tooltip that Keeps Target Hovered
Using with Chart Elements
Most chart elements support tooltips through thetooltip setting:
Pointer Positioning
The tooltip automatically positions its pointer based on:pointerOrientationsetting- Available space on screen
boundsconstraints- The
pointTocoordinates
vertical and horizontal orientations, the tooltip intelligently chooses the best direction.