Purpose
Based on the source implementation in~/workspace/source/src/component/tooltip/TooltipModel.ts, the tooltip component:
- Displays data details on mouse hover or click events
- Supports multiple trigger modes (item-based or axis-based)
- Can render in HTML or canvas/SVG (richText) mode
- Provides customizable formatting and styling
- Includes axis pointer indicators for better data reference
Basic Usage
Item Trigger Tooltip
Custom Tooltip Content
Axis Pointer with Cross Style
Configuration Options
Core Properties
Whether to display the tooltip component. From
TooltipModel.ts:99.Trigger type for tooltip:
'item': Triggered by data items (default)'axis': Triggered by axes, shows all series at the same axis value'none': No automatic trigger
TooltipModel.ts:106.Conditions to trigger tooltip. Can be:
'mousemove': Trigger on mouse movement'click': Trigger on click'mousemove|click': Trigger on either event'none': Manual trigger only
TooltipModel.ts:109.Whether to show tooltip content. Set to false to only show axis pointer without content box.See
TooltipModel.ts:102.Rendering Mode
Rendering mode for tooltip:
'auto': Use HTML by default, falls back to richText if document is unavailable'html': Render tooltip as HTML DOM element'richText': Render using canvas/SVG graphics
TooltipModel.ts:113.Specify where to append the tooltip DOM element. Only works when From
renderMode is ‘html’.TooltipModel.ts:72.CSS class name for the tooltip element. Only available when
renderMode is ‘html’.See TooltipModel.ts:78.Timing and Animation
Delay in milliseconds before showing the tooltip. From
TooltipModel.ts:120.Delay in milliseconds before hiding the tooltip. From
TooltipModel.ts:122.Animation transition duration in seconds. From
TooltipModel.ts:125.Whether to always show tooltip content without hiding on mouse out.From
TooltipModel.ts:111.Whether the mouse can enter the tooltip area. Useful for interactive tooltips with links.Implementation in
TooltipModel.ts:129.Positioning
Whether to confine tooltip within the chart area:
- For
renderMode: 'richText': defaults totrue - For
renderMode: 'html': defaults tofalse(for backward compatibility)
TooltipModel.ts:118.Styling
Background color of the tooltip. Default from
TooltipModel.ts:131.Border color of the tooltip. Can use
defaultBorderColor for multi-series scenarios.Border width of the tooltip in pixels. From
TooltipModel.ts:143.Border radius of the tooltip in pixels. From
TooltipModel.ts:140.Padding inside the tooltip. Can be:
- Single number for all sides
- Array
[top, right, bottom, left]
TooltipModel.ts:150.Shadow blur size for the tooltip box. From
TooltipModel.ts:134.Shadow color for the tooltip box. From
TooltipModel.ts:135.Horizontal shadow offset. From
TooltipModel.ts:136.Vertical shadow offset. From
TooltipModel.ts:137.Text style configuration. Default from
TooltipModel.ts:183-186:Extra CSS text to apply to the tooltip. Only works in HTML render mode.From
TooltipModel.ts:153.Content Formatting
Tooltip content formatter. Can be:String template with variables:Function for custom formatting:
{a}: series name{b}: data name / category{c}: data value{d}: percentage (for pie charts)
Order of items in tooltip when
trigger: 'axis'. Controls how multiple series are sorted.Axis Pointer
Axis pointer configuration. Used when
trigger: 'axis'. From TooltipModel.ts:156-182:Type of axis pointer indicator. From
TooltipModel.ts:159.Which axis the pointer should follow. ‘auto’ selects category axis by default.Implementation in
TooltipModel.ts:165.Whether to enable animation for axis pointer movement. From
TooltipModel.ts:167.Animation duration for pointer updates in milliseconds. From
TooltipModel.ts:168.Easing function for pointer animation. From
TooltipModel.ts:169.Style for cross pointer. From
TooltipModel.ts:171-178:Advanced Features
Multi-Series Default Border
Default border color when there are multiple series. Useful for maintaining visual consistency.From
TooltipModel.ts:145.Rich Text Rendering
When usingrenderMode: 'richText', tooltips are rendered using canvas/SVG, which provides:
- Better performance with large datasets
- No DOM manipulation overhead
- Consistent rendering across environments
- Automatic confinement to chart bounds