logo

G6

  • Docs
  • API
  • Playground
  • Community
  • Productsantv logo arrow
  • 5.0.45
  • 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 Overview
      • Shape Properties
  • Layout
    • Layout Overview
    • Build-in Layout
      • AntvDagre
      • Circular
      • ComboCombined
      • Common Layout Configuration Options
      • CompactBox
      • Concentric
      • D3Force
      • D3Force3D
      • Dagre
      • Dendrogram
      • Fishbone
      • Force
      • ForceAtlas2
      • Fruchterman
      • Grid Layout
      • Indented
      • Mds
      • Mindmap
      • Radial
      • Random
      • Snake
    • 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

Plugin Overview

Previous
Custom Behavior
Next
Background

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

What is a Plugin

A Plugin is the most flexible extension mechanism in G6, allowing users to extend G6's functionality, such as adding graphical components to the canvas or implementing undo/redo features.

Most customization needs can be achieved through plugins. G6 comes with some built-in plugins, such as: Tooltip, Grid, History.

Built-in Plugins

G6 provides a rich set of built-in plugins covering various common functional scenarios:

CategoryPlugin NameRegistration TypeDescription
Visual Style Enhancement
Grid Linegrid-lineDisplays grid reference lines on the canvas
BackgroundbackgroundAdds background images or colors to the canvas
WatermarkwatermarkAdds a watermark to the canvas to protect copyright
HullhullCreates an outline for a specified set of nodes
Bubble Setsbubble-setsCreates smooth bubble-like element outlines
SnaplinesnaplineDisplays alignment reference lines when dragging elements
Navigation and Overview
MinimapminimapDisplays a thumbnail preview of the graph, supporting navigation
FullscreenfullscreenSupports full-screen display and exit for charts
TimebartimebarProvides filtering and playback control for temporal data
Interactive Controls
ToolbartoolbarProvides a collection of common operation buttons
Context MenucontextmenuDisplays a menu of selectable operations on right-click
TooltiptooltipDisplays detailed information about elements on hover
LegendlegendDisplays categories and corresponding style descriptions of chart data
Data Exploration
FisheyefisheyeProvides a focus + context exploration experience
Edge Filter Lensedge-filter-lensFilters and displays edges within a specified area
Edge Bundlingedge-bundlingBundles edges with similar paths together to reduce visual clutter
Advanced Features
HistoryhistorySupports undo/redo operations
Camera Settingcamera-settingConfigures camera parameters in a 3D scene

For detailed configuration of each plugin, refer to the Built-in Plugin Documentation.

Configuration Methods

Basic Configuration

Specify the required plugins through the plugins array when initializing the graph instance:

import { Graph } from '@antv/g6';
const graph = new Graph({
// Other configurations...
plugins: ['grid', 'minimap', 'tooltip'],
});

Configuring Plugin Parameters

For plugins that require custom parameters, you can configure properties using the object form:

const graph = new Graph({
// Other configurations...
plugins: [
'grid',
{
type: 'tooltip',
key: 'my-tooltip', // Specify a key for the plugin for future updates
getContent: (e) => `<div>Node: ${e.target.id}</div>`,
},
],
});

Dynamically Updating Plugins

G6 supports dynamic management of plugins during the runtime of the graph instance to meet complex interaction needs:

Use the getPlugins method to get the current list of plugins:

// Get the list of plugins
const plugins = graph.getPlugins();
// console.log(plugins) 👉 ['minimap', 'grid']

You can adjust plugins using the setPlugins method:

// Add a new plugin
graph.setPlugins((plugins) => [...plugins, 'minimap']);
// Remove a plugin
graph.setPlugins((plugins) => plugins.filter((p) => p !== 'grid'));

You can update the configuration of a plugin using the updatePlugin method:

const graph = new Graph({
// Other configurations...
plugins: [
{
type: 'tooltip',
key: 'my-tooltip',
getContent: (e) => `<div>Node: ${e.target.id}</div>`,
},
],
});
// Update a single plugin
graph.updatePlugin({
key: 'my-tooltip',
getContent: (e) => `<div>Updated content: ${e.target.id}</div>`,
});

Note

When using the updatePlugin method, you need to specify a unique key for the plugin during initialization.

Uninstalling Plugins

Use the setPlugins method to uninstall plugins by setting the plugin configuration list to empty:

// Uninstall all plugins
graph.setPlugins([]);

Calling Plugin Methods

Some plugins provide API methods for users to call, such as the history plugin providing undo and redo methods, allowing users to implement undo and redo operations by calling these methods.

To call these methods, you need to first get the plugin instance, which can be obtained through the getPluginInstance method:

// Configure the plugin
const graph = new Graph({
plugins: [{ type: 'history', key: 'my-history' }],
});
// Get the plugin instance
const history = graph.getPluginInstance('my-history');
// Call plugin methods
history.undo();
history.redo();

Note

The graph.getPluginInstance method takes the plugin key value as a parameter, so if you need to get the plugin instance, you need to configure the corresponding plugin in the form of an object and pass in the key value.

For more plugin-related APIs, please refer to the Plugin API Documentation.

Custom Plugins

When built-in plugins cannot meet your needs, you can:

  • Inherit and extend existing plugins
  • Create brand new custom plugins

Custom plugins need to be registered before use. For detailed tutorials, please refer to the Custom Plugin documentation.

import { register, ExtensionCategory } from '@antv/g6';
import { MyCustomPlugin } from './my-custom-plugin';
// Register custom plugin
register(ExtensionCategory.PLUGIN, 'my-custom-plugin', MyCustomPlugin);
// Use custom plugin
const graph = new Graph({
plugins: ['my-custom-plugin'],
});

By reasonably combining and configuring plugins, you can build graph visualization applications with rich features and excellent interactive experiences.