logo

G6

  • Docs
  • API
  • Playground
  • Community
  • Productsantv logo arrow
  • 5.0.47
  • Introduction
  • Data
  • Getting Started
    • Quick Start
    • Installation
    • Integration
      • react
      • vue
      • angular
    • Step-by-step guide
  • Graph
    • Extensions En
    • Graph
    • Options
    • extension
  • Element
    • Element Overview
    • Element State
    • Node
      • Node Overview
      • Build-in Node
        • Common Node Configurations
        • Diamond
        • Donut
        • Ellipse
        • Hexagon
        • Html
        • Image
        • Rect
        • Star
        • Triangle
        • Circle
      • Custom Node
      • Define Nodes with React
    • Edge
      • Edge Overview
      • Build-in Edge
        • Common Edge Configurations
        • Cubic Bezier Curve
        • CubicHorizontal Bezier Curve
        • CubicVertical Bezier Curve
        • Line
        • Polyline
        • Quadratic Bezier Curve
      • Custom Edge
    • Combo
      • Combo Overview
      • Build-in Combo
        • Circle
        • Combo Configuration Options
        • Rect
      • Custom Combo
    • Shape
      • Shape and KeyShape
      • Atomic Shapes and Their Properties
      • Design and Implementation of Composite Shape
  • Layout
    • Layout Overview
    • Build-in Layout
      • 3D Force-Directed Layout
      • AntvDagre Layout
      • Circular Layout
      • ComboCombined Layout
      • Common Layout Configuration Options
      • CompactBox
      • Concentric Layout
      • D3 Force-Directed Layout
      • Dagre Layout
      • Dendrogram Layout
      • Fishbone Layout
      • Force Force-directed Layout
      • ForceAtlas2 Force-directed Layout
      • Fruchterman Force-directed Layout
      • Grid Layout
      • Indented Tree
      • MDS High-dimensional Data Dimensionality Reduction Layout
      • Mindmap Tree
      • Radial Layout
      • Random Layout
      • Snake Layout
    • Custom Layout
  • Behavior
    • Behavior Overview
    • Build-in Behavior
      • AutoAdaptLabel
      • BrushSelect
      • ClickSelect
      • CollapseExpand
      • CreateEdge
      • DragCanvas
      • DragElement
      • DragElementForce
      • FixElementSize
      • FocusElement
      • HoverActivate
      • LassoSelect
      • OptimizeViewportTransform
      • ScrollCanvas
      • ZoomCanvas
    • Custom Behavior
  • Plugin
    • Plugin Overview
    • Build-in Plugin
      • Background
      • BubbleSets
      • Contextmenu
      • EdgeBundling
      • EdgeFilterLens
      • Fisheye
      • Fullscreen
      • GridLine
      • History
      • Hull
      • Legend
      • Minimap
      • Snapline
      • Timebar
      • Toolbar
      • Tooltip
      • Watermark
    • Custom Plugin
  • Transform
    • Data Transformation Overview
    • Build-in Transform
      • MapNodeSize
      • PlaceRadialLabels
      • ProcessParallelEdges
    • Custom Transform
  • Theme
    • Theme Overview
    • Custom Theme
    • Palette
    • Custom Palette
  • Animation
    • Animation Overview
    • Custom Animation
  • Further Reading
    • Event
    • renderer
    • coordinate
    • download-image
    • Using Iconfont
    • Use 3D
    • Bundle Project
  • What's new
    • Feature
    • Upgrade To 5.0
  • FAQ
  • contribute

Tooltip

Previous
Toolbar
Next
Watermark

Resources

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-互动图形解决方案
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

Overview

The Tooltip is used to display additional information when the user hovers over elements in the graph. Tooltips can help users better understand the data in the graph and enhance the interactive experience.

Use Cases

  • When users need to know detailed information about an element, they can use the Tooltip to display this information.
  • In data visualization, Tooltips can be used to display detailed information about data points in a chart, helping users better understand the data.

Basic Usage

Below is a simple example of initializing the Tooltip plugin:

const graph = new Graph({
// Other configurations...
plugins: [
{
type: 'tooltip',
},
],
});

Configuration Options

PropertyDescriptionTypeDefault ValueRequired
typePlugin typestringtooltip✓
keyIdentifierstring-
positionTooltip positiontop | bottom | left | right | top-left | top-right | bottom-left | bottom-righttop-right
enableWhether the plugin is enabledboolean | ((event: IElementEvent, items: NodeData | EdgeData | ComboData[]) => boolean)true
getContentCustom content(event: IElementEvent, items: NodeData | EdgeData | ComboData[]) => Promise<HTMLElement | string>-
onOpenChangeCallback for show/hide(open: boolean) => void-
triggerTrigger behaviorhover | clickhover
containerCustom rendering container for tooltipstring | HTMLElement-
offsetOffset distance[number,number][10,10]
enterableWhether the pointer can enterbooleanfalse
titleTitlestring-
styleStyle objectRecord<string,any>{'.tooltip': { visibility: 'hidden'}}

enable

  • Whether to enable, supports passing a function to dynamically adjust the plugin logic

Only nodes use the tooltip plugin

const graph = new Graph({
// Other configurations...
plugins: [
{
type: 'tooltip',
enable:(e) => e.targetType === 'node';
},
],
});

getContent

  • Custom render Tooltip content, supports returning HTMLElement or string

Dynamically render custom HTML content

const graph = new Graph({
// Other configurations...
plugins: [
{
type: 'tooltip',
trigger: 'click',
getContent: (e, items) => {
let result = `<h4>Custom Content</h4>`;
items.forEach((item) => {
result += `<p>Type: ${item.data.description}</p>`;
});
return result;
},
},
],
});

onOpenChange

  • Callback for show/hide

Trigger tooltip display, can add custom buried point statistics reporting content

const graph = new Graph({
// Other configurations...
plugins: [
{
key: 'tooltip-click',
type: 'tooltip',
trigger: 'click',
onOpenChange: (open) => {
console.log('Tooltip open change');
},
},
],
});

trigger

Trigger behavior

  • 'hover': Triggered when the mouse enters the element
  • 'click': Triggered when the mouse clicks the element

Click the element to trigger the tooltip

const graph = new Graph({
// Other configurations...
plugins: [
{
key: 'tooltip-click',
type: 'tooltip',
trigger: 'click',
},
],
});

position

Display position supports the following values

  • top: Top
  • bottom: Bottom
  • left: Left
  • right: Right
  • top-left : Top left
  • top-right : Top right
  • bottom-left : Bottom left
  • bottom-right : Bottom right

Display at the bottom

const graph = new Graph({
// Other configurations...
plugins: [
{
key: 'tooltip-click',
type: 'tooltip',
position: 'bottom',
},
],
});

offset

Offset of the display position, based on the point where the mouse enters the element

const graph = new Graph({
// Other configurations...
plugins: [
{
key: 'tooltip-click',
type: 'tooltip',
position: 'bottom',
},
],
});

enterable

Whether the mouse pointer can enter the tooltip

The mouse can enter the tooltip

const graph = new Graph({
// Other configurations...
plugins: [
{
key: 'tooltip-click',
type: 'tooltip',
enterable: true,
},
],
});

style

Style object

Black element background color

const graph = new Graph({
// Other configurations...
plugins: [
{
key: 'tooltip-click',
type: 'tooltip',
style: {
['.tooltip']: {
backgroundColor: 'black',
},
},
},
],
});

Real Cases

createGraph(
{
data: {
nodes: [
{ id: 'node-0' },
{ id: 'node-1' },
{ id: 'node-2' },
{ id: 'node-3' },
{ id: 'node-4' },
{ id: 'node-5' },
],
edges: [
{ source: 'node-0', target: 'node-1' },
{ source: 'node-0', target: 'node-2' },
{ source: 'node-0', target: 'node-3' },
{ source: 'node-0', target: 'node-4' },
{ source: 'node-1', target: 'node-0' },
{ source: 'node-2', target: 'node-0' },
{ source: 'node-3', target: 'node-0' },
{ source: 'node-4', target: 'node-0' },
{ source: 'node-5', target: 'node-0' },
],
},
node: { style: { fill: '#7e3feb' } },
edge: { style: { stroke: '#8b9baf' } },
layout: { type: 'grid' },
behaviors: ['drag-canvas'],
plugins: ['grid-line', { type: 'tooltip', key: 'tooltip' }],
},
{ width: 600, height: 300 },
(gui, graph) => {
const options = {
type: 'tooltip',
trigger: 'hover',
enable: 'always',
position: 'top-left',
enterable: false,
};
const optionFolder = gui.addFolder('Tooltip Options');
optionFolder.add(options, 'type').disable(true);
optionFolder.add(options, 'trigger', ['click', 'hover']);
optionFolder.add(options, 'enable', ['always', 'node', 'edge']);
optionFolder.add(options, 'position', [
'top',
'bottom',
'left',
'right',
'top-left',
'top-right',
'bottom-left',
'bottom-right',
]);
optionFolder.add(options, 'enterable');
optionFolder.onChange((e) => {
const { enable, ...rest } = e.object;
let enableFn = () => true;
if ((enable === 'node') | (enable === 'edge')) {
enableFn = (e) => e.targetType === enable;
}
graph.updatePlugin({
key: 'tooltip',
enable: enableFn,
...rest,
});
graph.render();
});
// const apiFolder = gui.addFolder('Contextmenu API');
// const instance = graph.getPluginInstance('contextmenu');
// apiFolder.add(instance, 'hide');
},
);

Reference Examples:

  • Tooltip
  • Click to Trigger Tooltip
  • Show Different Tooltips When Hovering and Clicking the Same Element

API