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

Minimap

Previous
Legend
Next
Snapline

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 main function of the Minimap is to provide users with an overall layout of the current graph content in the form of a thumbnail, allowing quick positioning of graph operation locations.

Usage Scenarios

The Minimap plugin is mainly applicable to the following scenarios:

  • Providing a global view for quick area positioning
  • Navigation and interaction assistance, allowing quick positioning to the target location through the minimap

Basic Usage

Below is a simple example of initializing the Minimap plugin:

const graph = new Graph({
plugins: [
{
key: 'minimap',
type: 'minimap',
size: [240, 160],
},
],
});

Online Experience

minimap.md

createGraph(
{
data: {
nodes: Array.from({ length: 50 }).map((_, i) => ({
id: `node-${i}`,
x: Math.random() * 500,
y: Math.random() * 300,
})),
edges: Array.from({ length: 100 }).map((_, i) => ({
id: `edge-${i}`,
source: `node-${Math.floor(Math.random() * 50)}`,
target: `node-${Math.floor(Math.random() * 50)}`,
})),
},
node: { style: { fill: '#7e3feb' } },
edge: { style: { stroke: '#8b9baf' } },
layout: { type: 'force' },
behaviors: ['drag-canvas'],
plugins: [{ type: 'minimap', key: 'minimap', size: [240, 160], position: 'right-bottom' }],
},
{ width: 600, height: 300 },
(gui, graph) => {
const options = {
type: 'minimap',
width: 240,
height: 160,
shape: 'key',
padding: 10,
position: 'right-bottom',
maskStyleBorder: '1px solid #ddd',
maskStyleBackground: 'rgba(0, 0, 0, 0.1)',
containerStyleBorder: '1px solid #ddd',
containerStyleBackground: '#fff',
delay: 128,
};
const optionFolder = gui.addFolder('Minimap Options');
optionFolder.add(options, 'type').disable(true);
optionFolder
.add(options, 'width', 100, 500, 1)
.listen()
.onChange((value) => {
graph.updatePlugin({
key: 'minimap',
size: [value, options.height],
});
graph.render();
});
optionFolder
.add(options, 'height', 100, 500, 1)
.listen()
.onChange((value) => {
graph.updatePlugin({
key: 'minimap',
size: [options.width, value],
});
graph.render();
});
optionFolder
.add(options, 'shape', ['key'])
.listen()
.onChange((value) => {
graph.updatePlugin({
key: 'minimap',
shape: value,
});
graph.render();
});
optionFolder
.add(options, 'padding', 0, 50, 1)
.listen()
.onChange((value) => {
graph.updatePlugin({
key: 'minimap',
padding: value,
});
graph.render();
});
optionFolder
.add(options, 'position', ['right-bottom', 'left-bottom', 'right-top', 'left-top'])
.listen()
.onChange((value) => {
graph.updatePlugin({
key: 'minimap',
position: value,
});
graph.render();
});
optionFolder
.addColor(options, 'maskStyleBorder')
.listen()
.onChange((value) => {
graph.updatePlugin({
key: 'minimap',
maskStyle: { ...options.maskStyle, border: value },
});
graph.render();
});
optionFolder
.addColor(options, 'maskStyleBackground')
.listen()
.onChange((value) => {
graph.updatePlugin({
key: 'minimap',
maskStyle: { ...options.maskStyle, background: value },
});
graph.render();
});
optionFolder
.addColor(options, 'containerStyleBorder')
.listen()
.onChange((value) => {
graph.updatePlugin({
key: 'minimap',
containerStyle: { ...options.containerStyle, border: value },
});
graph.render();
});
optionFolder
.addColor(options, 'containerStyleBackground')
.listen()
.onChange((value) => {
graph.updatePlugin({
key: 'minimap',
containerStyle: { ...options.containerStyle, background: value },
});
graph.render();
});
optionFolder
.add(options, 'delay', 0, 500, 1)
.listen()
.onChange((value) => {
graph.updatePlugin({
key: 'minimap',
delay: value,
});
graph.render();
});
// Update the maskStyle and containerStyle in the options object
Object.defineProperty(options, 'maskStyle', {
get: () => ({
border: options.maskStyleBorder,
background: options.maskStyleBackground,
}),
set: (value) => {
options.maskStyleBorder = value.border;
options.maskStyleBackground = value.background;
},
});
Object.defineProperty(options, 'containerStyle', {
get: () => ({
border: options.containerStyleBorder,
background: options.containerStyleBackground,
}),
set: (value) => {
options.containerStyleBorder = value.border;
options.containerStyleBackground = value.background;
},
});
},
);

Configuration Options

PropertyDescriptionTypeDefault ValueRequired
typePlugin typestringminimap✓
keyUnique identifier for the plugin, used for subsequent updatesstring-
classNameClass name of the thumbnail canvas, not effective when an external container is passedstring
containerContainer to which the thumbnail is mounted, if not provided, it is mounted to the container where the Graph is locatedHTMLElement | string
containerStyleStyle of the thumbnail container, not effective when an external container is passedPartial<CSSStyleDeclaration>
delayDelay update time (milliseconds) for performance optimizationnumber128
filterFilter for filtering out elements that do not need to be displayed(id: string, elementType: node | edge | combo) => boolean
maskStyleStyle of the maskPartial<CSSStyleDeclaration>
paddingPaddingnumber | number[]10
positionPosition of the thumbnail relative to the canvas[number, number] | left | right | top | bottom | left-top | left-bottom | right-top | right-bottom | top-left | top-right | bottom-left | bottom-right | centerright-bottom
rendererRenderer, default is Canvas rendererIRenderer
shapeMethod for generating element thumbnailskey | ((id: string, elementType: node | edge | combo) => DisplayObject)key
sizeWidth and height[number, number][240, 160]

containerStyle

Set the style of the thumbnail container, not effective when an external container is passed. Inherits all CSS style properties (CSSStyleDeclaration), and you can use any valid CSS property to configure the style of the thumbnail container.

Below are some common configurations:

PropertyDescriptionTypeDefault ValueRequired
borderContainer border stylestring1px solid #ddd✓
backgroundContainer background colorstring#fff✓
borderRadiusContainer border radiusstring-
boxShadowContainer shadow effectstring-
paddingContainer paddingstring-
marginContainer marginstring-
opacityOpacitystring-

maskStyle

Specify the style of the mask. Inherits all CSS style properties (CSSStyleDeclaration), and you can use any valid CSS property to configure the style of the thumbnail container.

Below are some common configurations:

PropertyDescriptionTypeDefault ValueRequired
borderContainer border stylestring1px solid #ddd✓
backgroundContainer background colorstringrgba(0, 0, 0, 0.1)✓
borderRadiusContainer border radiusstring--
boxShadowContainer shadow effectstring--
paddingContainer paddingstring--
marginContainer marginstring--
opacityOpacitystring--

position

Position of the thumbnail relative to the canvas, the thumbnail position configuration supports array form and preset value form.

  • Array form [number, number] represents relative position, with a value range of 0~1. For example: [0, 0] represents the top left corner of the canvas, [1, 1] represents the bottom right corner of the canvas.
  • Preset value form is used to set the fixed position of the thumbnail on the canvas, optional values are: left | right | top | bottom | left-top | left-bottom | right-top | right-bottom | top-left | top-right | bottom-left | bottom-right | center
const graph = new Graph({
plugins:[
{
... // Other configurations
key: 'minimap',
type: 'minimap',
position: 'right-bottom' // Modify the position of the minimap here
}
]
})

The effect is as follows:

createGraph(
{
data: {
nodes: Array.from({ length: 50 }).map((_, i) => ({
id: `node-${i}`,
x: Math.random() * 500,
y: Math.random() * 300,
})),
edges: Array.from({ length: 100 }).map((_, i) => ({
id: `edge-${i}`,
source: `node-${Math.floor(Math.random() * 50)}`,
target: `node-${Math.floor(Math.random() * 50)}`,
})),
},
node: { style: { fill: '#7e3feb' } },
edge: { style: { stroke: '#8b9baf' } },
layout: { type: 'force' },
behaviors: ['drag-canvas'],
plugins: [{ type: 'minimap', key: 'minimap', size: [240, 160], position: 'right-bottom' }],
},
{ width: 600, height: 300 },
);

size

Set the width and height of the minimap, default value is [240, 160]

const graph = new Graph({
plugins:[
{
... // Other configurations
key: 'minimap',
type: 'minimap',
size: [200, 120] // Set the width and height of the minimap
}
]
})

The effect is as follows:

createGraph(
{
data: {
nodes: Array.from({ length: 50 }).map((_, i) => ({
id: `node-${i}`,
x: Math.random() * 500,
y: Math.random() * 300,
})),
edges: Array.from({ length: 100 }).map((_, i) => ({
id: `edge-${i}`,
source: `node-${Math.floor(Math.random() * 50)}`,
target: `node-${Math.floor(Math.random() * 50)}`,
})),
},
node: { style: { fill: '#7e3feb' } },
edge: { style: { stroke: '#8b9baf' } },
layout: { type: 'force' },
behaviors: ['drag-canvas'],
plugins: [{ type: 'minimap', key: 'minimap', size: [200, 120], position: 'right-bottom' }],
},
{ width: 600, height: 300 },
);

Practical Cases