logo

X6

  • Tutorials
  • API
  • Examples
  • Q&A
  • Change Log
  • XFlow
  • Productsantv logo arrow
  • 2.x
  • Introduction
  • Quickstart
  • Basic
    • Graph
    • Nodes
    • Edges
    • Connection Pile
    • Interaction
    • Events
    • Data Serialization
  • Intermediate
    • Connection Points
    • Tools
    • Group
    • React Nodes
    • Vue Nodes
    • Angular Nodes
    • HTML Nodes
  • Plugin
    • Graphic Transformations
    • Snapline
    • Clipboard
    • Keyboard
    • History
    • Selection Box
    • Scroller
    • Dnd
    • Mini Map
    • Stencil
    • Export
  • Upgrade to Version 2.x
  • Developer Tools

Tools

Previous
Connection Points
Next
Group

Resource

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-Interactive solution
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

This chapter mainly introduces knowledge related to tools. By reading, you can learn about

  • How to add tools for nodes or edges
  • What common tools are built into X6 by default

Using Tools

When creating nodes/edges, you can add tools through the tools option:

graph.addNode({
tools: [
{
name: 'button-remove', // Tool name
args: {
// Parameters corresponding to the tool
x: 10,
y: 10,
},
},
],
})
// If the parameters are empty, it can be abbreviated as:
graph.addNode({
tools: ['button-remove'],
})
graph.addEdge({
source,
target,
vertices: [
{
x: 90,
y: 160,
},
{
x: 210,
y: 160,
},
],
tools: ['vertices', 'segments'],
})

After nodes/edges are created, you can call methods like hasTool(name), addTools(...), and removeTools() to add or remove tools.

Built-in Tools

Tools are widgets rendered on nodes/edges to enhance their interactivity. We provide the following built-in tools for nodes and edges:

Nodes:

  • button Renders a button at a specified position, supporting custom click interactions for the button.
  • button-remove Renders a delete button at a specified position, which deletes the corresponding node when clicked.
  • boundary Renders a rectangle surrounding the node based on its bounding box. Note that this tool only renders a rectangle without any interaction.

Edges:

  • vertices Path point tool that renders a small dot at the path point position. You can drag the dot to modify the path point position, double-click the dot to delete the path point, and click on the edge to add a path point.
  • segments Segment tool that renders a toolbar at the center of each line segment of the edge. You can drag the toolbar to adjust the positions of the path points at both ends of the segment.
  • boundary Renders a rectangle surrounding the edge based on its bounding box. Note that this tool only renders a rectangle without any interaction.
  • button Renders a button at a specified position, supporting custom click interactions for the button.
  • button-remove Renders a delete button at a specified position, which deletes the corresponding edge when clicked.
  • source-arrowhead and target-arrowhead Renders a shape (default is an arrow) at the start or end of the edge, allowing you to drag the shape to modify the start or end of the edge.