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

Graphic Transformations

Previous
HTML Nodes
Next
Snapline

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...

In this chapter, we mainly introduce the graphic transformation plugin. By reading, you can learn about

  • How to adjust node size using the interactive plugin
  • How to adjust node rotation angle using the interactive plugin

Usage

Using UI components to adjust node size and angle is a common requirement. We provide a standalone plugin package @antv/x6-plugin-transform to utilize this functionality.

# npm
$ npm install @antv/x6-plugin-transform --save
# yarn
$ yarn add @antv/x6-plugin-transform

Then we can use it in our code like this:

import { Transform } from '@antv/x6-plugin-transform'
const graph = new Graph({
background: {
color: '#F2F7FA',
},
})
graph.use(
new Transform({
resizing: resizingOptions,
rotating: rotatingOptions,
}),
)

Demo

First, let's experience interactive resizing of nodes (clicking on a node brings up the operation component):

Next, let's experience interactive rotation of nodes (clicking on a node brings up the operation component):

Configuration

Resizing

Property NameTypeDefault ValueRequiredDescription
enabledbooleanfalseWhether resizing of nodes is supported
minWidthnumber0Minimum resizing width
minHeightnumber0Minimum resizing height
maxWidthnumberInfinityMaximum resizing width
maxHeightnumberInfinityMaximum resizing height
orthogonalbooleantrueWhether to show intermediate resizing points
restrictbooleanfalseWhether resizing boundaries can exceed canvas edges
autoScrollbooleantrueWhether to automatically scroll the canvas when dragging exceeds its bounds
preserveAspectRatiobooleanfalseWhether to maintain the aspect ratio during resizing
allowReversebooleantrueWhether to allow control points to drag in reverse when reaching minimum width or height

The above configuration supports dynamic modification using functions as well:

new Transform({
resizing: {
enabled: true,
orthogonal(node: Node) {
const { enableOrthogonal } = node.getData()
return enableOrthogonal
},
},
})

Rotating

Property NameTypeDefault ValueRequiredDescription
enabledbooleanfalseWhether rotating of nodes is supported
gridnumber15Angle of rotation per step

The above configuration also supports dynamic modification using functions:

new Transform({
rotating: {
enabled: true,
grid() {
return 30
},
},
})

API

graph.createTransformWidget(node: Node)

Creates a transform control for the node.

graph.clearTransformWidgets()

Clears all transform controls.

Events

Event NameParameter TypeDescription
node:resize{ e: Dom.MouseDownEvent; x: number; y: number; node: Node; view: NodeView }Triggered when resizing starts
node:resizing{ e: Dom.MouseMoveEvent; x: number; y: number; node: Node; view: NodeView }Triggered during resizing
node:resized{ e: Dom.MouseUpEvent; x: number; y: number; node: Node; view: NodeView }Triggered after resizing
node:rotate{ e: Dom.MouseDownEvent; x: number; y: number; node: Node; view: NodeView }Triggered when rotation starts
node:rotating{ e: Dom.MouseMoveEvent; x: number; y: number; node: Node; view: NodeView }Triggered during rotation
node:rotated{ e: Dom.MouseUpEvent; x: number; y: number; node: Node; view: NodeView }Triggered after rotation
graph.on('node:rotated', ({ node }) => {
console.log(node.angle())
})
// We can also listen to events on the plugin instance
transform.on('node:rotated', ({ node }) => {
console.log(node.angle())
})
Resizing Settings
minWidth
1
maxWidth
200
minHeight
1
maxHeight
150
Rotating Settings
grid
15