Loading...
Compared to 2.x, 3.x mainly focuses on plugin consolidation (unified export), optimized default interactions, introduces animation capabilities, and adds virtual rendering support. The upgrade cost is low.
@antv/x6-plugin-xxxx, @antv/x6-common, and @antv/x6-geometry are merged into the main @antv/x6 package and exported from there.panning is enabled by default.Scroller, virtual rendering is available via virtual: true for large graphs.3.x merges commonly used plugins and subpackages into @antv/x6, so you no longer need to install separate @antv/x6-plugin-xxxx packages. Additionally, the utility package @antv/x6-common and geometry package @antv/x6-geometry are now part of the main package, and their APIs should be imported from @antv/x6.
{"@antv/x6": "^3.0.0"}
Remove the following dependencies if present:
@antv/x6-plugin-selection@antv/x6-plugin-transform@antv/x6-plugin-scroller@antv/x6-plugin-keyboard@antv/x6-plugin-history@antv/x6-plugin-clipboard@antv/x6-plugin-snapline@antv/x6-plugin-dnd@antv/x6-plugin-minimap@antv/x6-plugin-stencil@antv/x6-plugin-export@antv/x6-common@antv/x6-geometryStarting from 3.x, the plugins above are exported from @antv/x6. Usage remains the same; simply replace the import path:
// 2.ximport { Scroller } from '@antv/x6-plugin-scroller'import { Selection } from '@antv/x6-plugin-selection'graph.use(new Scroller())graph.use(new Selection())// 3.ximport { Scroller, Selection } from '@antv/x6'graph.use(new Scroller())graph.use(new Selection())
In 3.x, utilities and geometry types previously imported from @antv/x6-common and @antv/x6-geometry are now exported directly from @antv/x6. You only need to update the import path:
// 2.ximport { Dom, FunctionExt } from '@antv/x6-common'import { Point, Rectangle } from '@antv/x6-geometry'// 3.ximport { Dom, FunctionExt, Point, Rectangle } from '@antv/x6'
3.x introduces animate and removes the 2.x transition API, making it easier to add effects to nodes and edges.
See more: Animation Docs.
panning is enabled by default (enabled: true). To disable, set panning: false.panning conflicts with Selection rubberband triggers, Selection takes precedence.Scroller, graph panning is disabled by default to avoid interaction conflicts, and virtual rendering can be enabled via virtual: true.@antv/x6-react-shape@^3.x, @antv/x6-vue-shape@^3.x, and @antv/x6-angular-shape@^3.x.{"@antv/x6-react-shape": "^3.0.0","@antv/x6-vue-shape": "^3.0.0","@antv/x6-angular-shape": "^3.0.0"}
Change 2.x Portal.getProvider() to 3.x getProvider():
// 2.ximport { Portal } from '@antv/x6-react-shape'const Provider = Portal.getProvider()// 3.ximport { getProvider } from '@antv/x6-react-shape'const Provider = getProvider()