logo

G6

  • Docs
  • API
  • Playground
  • Community
  • Productsantv logo arrow
  • 5.0.49
  • 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
      • Common Node Configuration
      • Circle Node
      • Diamond Node
      • Donut Node
      • Ellipse Node
      • Hexagon Node
      • HTML Node
      • Image Node
      • Rect Node
      • Star Node
      • Triangle Node
      • Custom Node
      • Define Nodes with React
    • Edge
      • Edge Overview
      • Edge Common Configuration
      • Cubic Bezier Curve Edge
      • CubicHorizontal Bezier Curve Edge
      • CubicVertical Bezier Curve Edge
      • Line Edge
      • Polyline Edge
      • Quadratic Bezier Curve Edge
      • Custom Edge
    • Combo
      • Combo Overview
      • Combo Common Options
      • Circle Combo
      • Rect Combo
      • Custom Combo
    • Shape
      • Shape and KeyShape
      • Atomic Shapes and Their Properties
      • Design and Implementation of Composite Shape
  • Layout
    • Layout Overview
    • Common Layout Configuration Options
    • AntvDagre Layout
    • Circular Layout
    • ComboCombined Layout
    • CompactBox Layout
    • Concentric Layout
    • 3D Force-Directed Layout
    • D3 Force-Directed Layout
    • Dagre Layout
    • Dendrogram Layout
    • Fishbone Layout
    • ForceAtlas2 Force-directed Layout
    • 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
    • ZoomCanvas
    • AutoAdaptLabel
    • BrushSelect
    • ClickSelect
    • CollapseExpand
    • CreateEdge
    • DragCanvas
    • DragElement
    • DragElementForce
    • FixElementSize
    • FocusElement
    • HoverActivate
    • LassoSelect
    • OptimizeViewportTransform
    • ScrollCanvas
    • Custom Behavior
  • Plugin
    • Plugin Overview
    • Background
    • BubbleSets
    • Contextmenu
    • EdgeBundling
    • EdgeFilterLens
    • Fisheye
    • Fullscreen
    • GridLine
    • History
    • Hull
    • Legend
    • Minimap
    • Snapline
    • Timebar
    • Toolbar
    • Tooltip
    • Watermark
    • Custom Plugin
  • Transform
    • Data Transformation Overview
    • 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

Combo Common Options

Previous
Combo Overview
Next
Circle Combo

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 document introduces the built-in combo common property configurations.

ComboOptions

import { Graph } from '@antv/g6';
const graph = new Graph({
combo: {
type: 'circle', // Combo type
style: {}, // Combo style
state: {}, // State style
palette: {}, // Palette configuration
animation: {}, // Animation configuration
},
});
PropertyDescriptionTypeDefaultRequired
typeCombo type, built-in combo type name or custom combo nameTypecircle
styleCombo style configuration, including color, size, etc.Style-
stateStyle configuration for different statesState-
paletteDefine combo palette for mapping colors based on dataPalette-
animationDefine combo animation effectsAnimation-

Type

Specifies the combo type, built-in combo type name or custom combo name. Default is circle. ⚠️ Note: This determines the shape of the main graphic.

const graph = new Graph({
combo: {
type: 'circle',
},
});

⚠️ Dynamic Configuration Note: The type property also supports dynamic configuration, allowing you to dynamically select combo types based on combo data:

const graph = new Graph({
combo: {
// Static configuration
type: 'circle',
// Dynamic configuration - arrow function form
type: (datum) => datum.data.comboType || 'circle',
// Dynamic configuration - regular function form (can access graph instance)
type: function (datum) {
console.log(this); // graph instance
return datum.data.category === 'important' ? 'rect' : 'circle';
},
},
});

Available values:

  • circle: Circle Combo
  • rect: Rect Combo

Style

Defines combo style, including color, size, etc.

const graph = new Graph({
combo: {
style: {},
},
});

⚠️ Dynamic Configuration Note: All style properties below support dynamic configuration, meaning you can pass functions to dynamically calculate property values based on combo data:

const graph = new Graph({
combo: {
style: {
// Static configuration
fill: '#1783FF',
// Dynamic configuration - arrow function form
stroke: (datum) => (datum.data.isActive ? '#FF0000' : '#000000'),
// Dynamic configuration - regular function form (can access graph instance)
lineWidth: function (datum) {
console.log(this); // graph instance
return datum.data.importance > 5 ? 3 : 1;
},
// Nested properties also support dynamic configuration
labelText: (datum) => `Combo: ${datum.id}`,
badges: (datum) => datum.data.tags.map((tag) => ({ text: tag })),
},
},
});

Where the datum parameter is the combo data object (ComboData), containing all combo data information.

A complete combo consists of the following parts:

  • key: The main graphic of the combo, representing the primary shape of the combo, such as circle, rectangle, etc.
  • label: Text label, usually used to display the combo's name or description
  • halo: Graphic displaying halo effect around the main graphic
  • badge: Badge displayed at the top-right corner of the combo by default

The following style configurations will be explained by atomic graphics:

Main Graphic Style

The main graphic is the core part of the combo, defining the basic shape and appearance of the combo. Here are common configuration scenarios:

Basic Style Configuration

Set the basic appearance of the combo:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 200,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
fill: '#5B8FF9', // Blue fill
stroke: '#1A1A1A', // Dark stroke
lineWidth: 2,
fillOpacity: 0.2,
},
},
});
graph.render();

Transparency and Shadow Effects

Add transparency and shadow effects to combos:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 200,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
fill: '#61DDAA',
fillOpacity: 0.15,
shadowColor: 'rgba(97, 221, 170, 0.4)',
shadowBlur: 12,
shadowOffsetX: 2,
shadowOffsetY: 4,
stroke: '#F0F0F0',
lineWidth: 1,
},
},
});
graph.render();

Dashed Border Style

Create combos with dashed borders:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 200,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
fill: '#FFF1F0',
fillOpacity: 0.1,
stroke: '#F5222D',
lineWidth: 2,
lineDash: [6, 4],
lineCap: 'round',
},
},
});
graph.render();

Here is the complete main graphic style configuration:

PropertyDescriptionTypeDefaultRequired
collapsedWhether the current combo is collapsedbooleanfalse
cursorCombo mouse hover style, optionsstringdefault
fillCombo fill colorstring#99ADD1
fillOpacityCombo fill opacitynumber | string0.04
increasedLineWidthForHitTestingWhen lineWidth is small, the interactive area becomes small. Sometimes we want to increase this area to make "thin lines" easier to picknumber0
lineCapCombo stroke end cap styleround | square | buttbutt
lineDashCombo stroke dash stylenumber[]-
lineDashOffsetCombo stroke dash offsetnumber-
lineJoinCombo stroke join styleround | bevel | mitermiter
lineWidthCombo stroke widthnumber1
opacityCombo opacitynumber | string1
pointerEventsHow combo responds to pointer events, optionsstringauto
shadowBlurCombo shadow blurnumber-
shadowColorCombo shadow colorstring-
shadowOffsetXCombo shadow offset in x directionnumber | string-
shadowOffsetYCombo shadow offset in y directionnumber | string-
shadowTypeCombo shadow typeinner | outerouter
sizeCombo size, quick setting for combo width and height, optionsnumber | number[]-
strokeCombo stroke colorstring#99ADD1
strokeOpacityCombo stroke opacitynumber | string1
transformTransform property allows you to rotate, scale, skew or translate the given combostring-
transformOriginRotation and scaling center, also called transformation centerstring-
visibilityWhether combo is visiblevisible | hiddenvisible
xCombo x coordinatenumber0
yCombo y coordinatenumber0
zCombo z coordinatenumber0
zIndexCombo rendering layernumber0

Size

Combo size, quick setting for combo width and height, supports three configuration methods:

  • number: Indicates that combo width and height are the same as the specified value
  • [number, number]: Indicates that combo width and height are represented by array elements in order for combo width and height
  • [number, number, number]: Indicates that combo width, height, and depth are represented by array elements in order

PointerEvents

The pointerEvents property controls how graphics respond to interaction events. Refer to MDN documentation.

Available values: visible | visiblepainted | visiblestroke | non-transparent-pixel | visiblefill | visible | painted | fill | stroke | all | none | auto | inherit | initial | unset

In short, fill, stroke, and visibility can independently or in combination affect pick testing behavior. Currently supports the following keywords:

  • auto: Default value, equivalent to visiblepainted
  • none: Will never be the target of responding events
  • visiblepainted: Will respond to events only when the following conditions are met:
    • visibility is set to visible, i.e., the graphic is visible
    • Triggered in the graphic fill area and fill takes a non-none value; or triggered in the graphic stroke area and stroke takes a non-none value
  • visiblefill: Will respond to events only when the following conditions are met:
    • visibility is set to visible, i.e., the graphic is visible
    • Triggered in the graphic fill area, not affected by the fill value
  • visiblestroke: Will respond to events only when the following conditions are met:
    • visibility is set to visible, i.e., the graphic is visible
    • Triggered in the graphic stroke area, not affected by the stroke value
  • visible: Will respond to events only when the following conditions are met:
    • visibility is set to visible, i.e., the graphic is visible
    • Triggered in the graphic fill or stroke area, not affected by fill and stroke values
  • painted: Will respond to events only when the following conditions are met:
    • Triggered in the graphic fill area and fill takes a non-none value; or triggered in the graphic stroke area and stroke takes a non-none value
    • Not affected by visibility value
  • fill: Will respond to events only when the following conditions are met:
    • Triggered in the graphic fill area, not affected by the fill value
    • Not affected by visibility value
  • stroke: Will respond to events only when the following conditions are met:
    • Triggered in the graphic stroke area, not affected by the stroke value
    • Not affected by visibility value
  • all: Will respond to events as long as entering the graphic fill and stroke areas, not affected by fill, stroke, visibility values

Usage Examples:

// Example 1: Only stroke area responds to events
const graph = new Graph({
combo: {
style: {
fill: 'none',
stroke: '#000',
lineWidth: 2,
pointerEvents: 'stroke', // Only stroke responds to events
},
},
});
// Example 2: Does not respond to events at all
const graph = new Graph({
combo: {
style: {
pointerEvents: 'none', // Combo does not respond to any events
},
},
});

Cursor

Available values: auto | default | none | context-menu | help | pointer | progress | wait | cell | crosshair | text | vertical-text | alias | copy | move | no-drop | not-allowed | grab | grabbing | all-scroll | col-resize | row-resize | n-resize | e-resize | s-resize | w-resize | ne-resize | nw-resize | se-resize | sw-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | zoom-in | zoom-out

Style When Expanded

Main graphic style when the combo is expanded

AttributeDescriptionTypeDefaultRequired
collapsedWhether the combo is currently collapsedbooleanfalse
cursorCombo mouse hover style, configuration itemstringdefault
fillCombo fill colorstring#99ADD1
fillOpacityCombo fill color opacitynumber  string0.04
increasedLineWidthForHitTestingWhen lineWidth is small, the interactive area also becomes smaller. Sometimes we want to enlarge this area to make "thin lines" easier to pick upnumber0
lineCapCombo stroke end styleround  square  buttbutt
lineDashCombo stroke dash stylenumber[]-
lineDashOffsetCombo stroke dash offsetnumber-
lineJoinCombo stroke join styleround  bevel  mitermiter
lineWidthCombo stroke widthnumber1
opacityCombo opacitynumber  string1
shadowBlurCombo shadow blurnumber-
shadowColorCombo shadow colorstring-
shadowOffsetXCombo shadow offset in the x-axis directionnumber  string-
shadowOffsetYCombo shadow offset in the y-axis directionnumber  string-
shadowTypeCombo shadow typeinner  outerouter
strokeCombo stroke colorstring#99add1
strokeOpacityCombo stroke color opacitynumber  string1
visibilityWhether the combo is visiblevisible  hiddenvisible
xCombo x coordinatenumber0
yCombo y coordinatenumber0
zCombo z coordinatenumber0
zIndexCombo rendering layernumber0
{styleProps}More graphic configurations, refer to BaseStyleProps configuration itemsBaseStyleProps-

Cursor

Optional values are: auto | default | none | context-menu | help | pointer | progress | wait | cell | crosshair | text | vertical-text | alias | copy | move | no-drop | not-allowed | grab | grabbing | all-scroll | col-resize | row-resize | n-resize | e-resize | s-resize | w-resize | ne-resize | nw-resize | se-resize | sw-resize | ew-resize | ns-resize | nesw-resize | nwse-resize | zoom-in | zoom-out

Example:

const graph = new Graph({
// Other configurations...
combo: {
style: {
fill: '#1783FF', // Fill color
stroke: '#000', // Stroke color
lineWidth: 2, // Stroke width
},
},
});

The effect is as follows:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: { fill: '#1783FF', stroke: '#000', lineWidth: 2 },
},
});
graph.render();

Style When Collapsed

Effective when collapsed is true

AttributeDescriptionTypeDefaultRequired
collapsedCursorMouse hover style when the combo is collapsed, configuration itemstringSame as the cursor when expanded
collapsedFillFill color when the combo is collapsedstringSame as the fill when expanded
collapsedFillOpacityFill color opacity when the combo is collapsednumber  string1
collapsedIncreasedLineWidthForHitTestingWhen the combo is collapsed, if lineWidth is small, the interactive area also becomes smaller. Sometimes we want to enlarge this area to make "thin lines" easier to pick upnumber0
collapsedLineCapStroke end style when the combo is collapsedround  square  buttSame as the lineCap when expanded
collapsedLineDashStroke dash style when the combo is collapsednumber[]Same as the lineDash when expanded
collapsedLineDashOffsetStroke dash offset when the combo is collapsednumberSame as the lineDashOffset when expanded
collapsedLineJoinStroke join style when the combo is collapsedround  bevel  miterSame as the lineJoin when expanded
collapsedLineWidthStroke width when the combo is collapsednumberSame as the lineWidth when expanded
collapsedMarkerWhether to display the marker when the combo is collapsed, configuration itembooleantrue
collapsedOpacityOpacity when the combo is collapsednumber  stringSame as the opacity when expanded
collapsedShadowBlurShadow blur when the combo is collapsednumberSame as the shadowBlur when expanded
collapsedShadowColorShadow color when the combo is collapsedstringSame as the shadowColor when expanded
collapsedShadowOffsetXShadow offset in the x-axis direction when the combo is collapsednumber  stringSame as the shadowOffsetX when expanded
collapsedShadowOffsetYShadow offset in the y-axis direction when the combo is collapsednumber  stringSame as the shadowOffsetY when expanded
collapsedShadowTypeShadow type when the combo is collapsedinner  outerSame as the shadowType when expanded
collapsedSizeSize when the combo is collapsednumber | [number, number] | [number, number, number]32
collapsedStrokeStroke color when the combo is collapsedstringSame as the stroke when expanded
collapsedStrokeOpacityStroke color opacity when the combo is collapsednumber  stringSame as the strokeOpacity when expanded
collapsedVisibilityWhether the combo is visible when collapsedvisible  hiddenSame as the visibility when expanded
collapsed{styleProps}More graphic configurations, refer to BaseStyleProps configuration itemsBaseStyleProps-

Example:

const graph = new Graph({
// Other configurations...
combo: {
style: {
collapsedFill: '#1783FF', // Fill color
collapsedStroke: '#000', // Stroke color
collapsedLineWidth: 2, // Stroke width
},
},
});

The effect is as follows:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1', style: { collapsed: true } }],
},
combo: {
style: { collapsedFill: '#1783FF', collapsedStroke: '#000', collapsedLineWidth: 2 },
},
});
graph.render();

Collapsed Marker Style

Effective when collapsedMarker is true

AttributeDescriptionTypeDefaultRequired
collapsedMarkerTypeMarker type displayed when the combo is collapsed
- 'child-count': Number of child elements (including Node and Combo)
- 'descendant-count': Number of descendant elements (including Node and Combo)
- 'node-count': Number of descendant elements (only including Node)
- (children: NodeLikeData[]) => string: Custom processing logic
child-count | descendant-count | node-count | ((children: NodeData | ComboData[]) => string)child-count
collapsedMarkerFillIcon text colorstring#fff
collapsedMarkerFillOpacityIcon text color opacitynumber1
collapsedMarkerFontSizeIcon font sizenumber12
collapsedMarkerFontWeightIcon font weightnumber | stringnormal
collapsedMarkerRadiusIcon corner radiusnumber0
collapsedMarkerSrcImage source. Its priority is higher than collapsedMarkerTextstring-
collapsedMarkerTextIcon textstring-
collapsedMarkerTextAlignIcon text horizontal alignmentcenter  end  left  right  startcenter
collapsedMarkerTextBaselineIcon text alignment baselinealphabetic  bottom  hanging  ideographic  middle  topmiddle
collapsedMarkerWidthIcon widthnumber-
collapsedMarkerHeightIcon heightnumber-
collapsedMarkerZIndexIcon rendering layernumber1
collapsedMarker{StyleProps}More icon style configurations, refer to TextStyleProps, ImageStyleProps configuration items. For example, collapsedMarkerFontSize represents the font size of the text iconTextStyleProps | ImageStyleProps-

Example:

const graph = new Graph({
// Other configurations...
combo: {
style: {
collapsedMarkerFill: '#1783FF', // Fill color
collapsedMarkerFontSize: 30, // Icon font size
},
},
});

The effect is as follows:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
nodes: [
{ id: 'node1', combo: 'combo1' },
{ id: 'node2', combo: 'combo1' },
],
combos: [{ id: 'combo1', style: { collapsed: true } }],
},
combo: {
style: {
collapsedMarkerFill: '#1783FF',
collapsedMarkerFontSize: 30,
},
},
});
graph.render();

Label Style

Labels are used to display text information for combos, supporting rich text style configuration and flexible position layout.

Basic Label Configuration

Add basic text label to combo:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
labelText: 'Sales Department', // Label text content
labelFill: '#1A1A1A', // Label text color
labelFontSize: 14, // Label font size
labelPlacement: 'bottom', // Label position: bottom
},
},
});
graph.render();

Multi-line Text Label

Configure labels that support multi-line display:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 120,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
labelText: 'This is a combo label text content that supports multi-line display',
labelWordWrap: true, // Enable text wrapping
labelMaxWidth: 100, // Maximum width 100px
labelMaxLines: 3, // Maximum 3 lines
labelTextAlign: 'center', // Center text alignment
labelFontSize: 12,
},
},
});
graph.render();

Custom Style Label

Create labels with special styles:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
labelText: 'IMPORTANT',
labelFill: '#FF4D4F', // Red text
labelFontSize: 16,
labelFontWeight: 'bold', // Bold
labelFontStyle: 'italic', // Italic
labelTextDecorationLine: 'underline', // Underline
labelLetterSpacing: 2, // Letter spacing
labelPlacement: 'top',
},
},
});
graph.render();

Here are the complete label style configurations:

PropertyDescriptionTypeDefaultRequired
labelWhether to show combo labelbooleantrue
labelCursorCursor style when hovering over combo label, optionsstringdefault
labelFillCombo label text colorstring#000
labelFillOpacityCombo label text color opacitynumber1
labelFontFamilyCombo label font familystring-
labelFontSizeCombo label font sizenumber12
labelFontStyleCombo label font stylenormal | italic | oblique-
labelFontVariantCombo label font variantnormal | small-caps | string-
labelFontWeightCombo label font weightnormal | bold | bolder | lighter | number400
labelLeadingLine spacingnumber0
labelLetterSpacingCombo label letter spacingnumber | string-
labelLineHeightCombo label line heightnumber | string-
labelMaxLinesCombo label maximum linesnumber1
labelMaxWidthCombo label maximum width, optionsnumber | string200%
labelOffsetXCombo label X offsetnumber0
labelOffsetYCombo label Y offsetnumber0
labelPaddingCombo label paddingnumber | number[]0
labelPlacementCombo label position relative to combo main graphic, optionsstringbottom
labelTextCombo label text contentstring-
labelTextAlignCombo label text horizontal alignmentstart | center | middle | end | left | rightleft
labelTextBaselineCombo label text baselinetop | hanging | middle | alphabetic | ideographic | bottom-
labelTextDecorationColorCombo label text decoration colorstring-
labelTextDecorationLineCombo label text decoration linestring-
labelTextDecorationStyleCombo label text decoration stylesolid | double | dotted | dashed | wavy-
labelTextOverflowCombo label text overflow handlingclip | ellipsis | string-
labelTextPathCombo label text pathPath-
labelWordWrapWhether combo label enables auto line wrapping. When labelWordWrap is enabled, parts exceeding labelMaxWidth automatically wrapbooleanfalse
labelZIndexCombo label rendering layernumber0
label{StyleProps}More label style configurations, refer to TextStyleProps property values. For example, labelOpacity represents label opacityTextStyleProps-

LabelPlacement

Label position relative to combo main graphic, available values:

  • center: Label at combo center
  • top, bottom, left, right: Label at top, bottom, left, right of combo
  • top-left, top-right, bottom-left, bottom-right: Label at four corners of combo
  • left-top, left-bottom, right-top, right-bottom: Label at edge endpoints of combo

LabelMaxWidth

When auto line wrapping labelWordWrap is enabled, text wraps when exceeding this width:

  • string: Defines maximum width as percentage relative to combo element width. For example, 50% means label width doesn't exceed half of combo width
  • number: Defines maximum width in pixels. For example, 100 means label maximum width is 100 pixels

For example, setting multi-line label text:

{
"labelWordWrap": true,
"labelMaxWidth": 200,
"labelMaxLines": 3
}

Label Background Style

Label background provides background decoration for label text, improving label readability and visual effects.

Basic Background Style

Add simple background to label:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
labelText: 'Important Combo',
labelFill: '#fff', // White text
labelBackground: true, // Enable background
labelBackgroundFill: '#1783FF', // Blue background
labelBackgroundPadding: [4, 8], // Padding: vertical 4px, horizontal 8px
labelBackgroundRadius: 4, // Border radius
},
},
});
graph.render();

Gradient Background Effect

Create label background with gradient effect:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
labelText: 'VIP Combo',
labelFill: '#fff',
labelFontWeight: 'bold',
labelBackground: true,
labelBackgroundFill: 'linear-gradient(45deg, #FF6B6B, #4ECDC4)', // Gradient background
labelBackgroundPadding: [6, 12],
labelBackgroundRadius: 20, // Large border radius
labelBackgroundShadowColor: 'rgba(0,0,0,0.2)',
labelBackgroundShadowBlur: 4,
labelBackgroundShadowOffsetY: 2,
},
},
});
graph.render();

Stroke-only Background Style

Create label background with stroke only:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
labelText: 'Border Label',
labelFill: '#1783FF',
labelBackground: true,
labelBackgroundFill: 'transparent', // Transparent background
labelBackgroundStroke: '#1783FF', // Blue stroke
labelBackgroundLineWidth: 2, // Stroke width
labelBackgroundPadding: [4, 8],
labelBackgroundRadius: 8,
},
},
});
graph.render();

Here are the complete label background style configurations:

PropertyDescriptionTypeDefault
labelBackgroundWhether to show combo label backgroundbooleanfalse
labelBackgroundCursorCombo label background cursor style, optionsstringdefault
labelBackgroundFillCombo label background fill colorstring#000
labelBackgroundFillOpacityCombo label background opacitynumber0.75
labelBackgroundHeightCombo label background heightstring | number-
labelBackgroundLineDashCombo label background dash configurationnumber | string |(number | string )[]-
labelBackgroundLineDashOffsetCombo label background dash offsetnumber-
labelBackgroundLineWidthCombo label background stroke line widthnumber-
labelBackgroundPaddingCombo label background paddingnumber | number[][2, 4, 2, 4]
labelBackgroundRadiusCombo label background border radius
- number: Set all four corner radius uniformly
- number[]: Set four corner radius separately, missing values auto-filled
number | number[]0
labelBackgroundShadowBlurCombo label background shadow blurnumber-
labelBackgroundShadowColorCombo label background shadow colorstring-
labelBackgroundShadowOffsetXCombo label background shadow X offsetnumber-
labelBackgroundShadowOffsetYCombo label background shadow Y offsetnumber-
labelBackgroundStrokeCombo label background stroke colorstring-
labelBackgroundStrokeOpacityCombo label background stroke opacitynumber | string1
labelBackgroundVisibilityWhether combo label background is visiblevisible | hidden-
labelBackgroundZIndexCombo label background rendering layernumber1
labelBackground{StyleProps}More label background style configurations, refer to RectStyleProps property values. For example, labelBackgroundOpacity represents label background opacityRectStyleProps-

Badge Style

Badges are small markers displayed on combos, usually used to show status, quantity, or other auxiliary information. Multiple badges can be displayed simultaneously with customizable positions.

Single Badge

Add a simple badge to the combo:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 200,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
badges: [
{ text: 'NEW' }, // Display at top by default
],
},
},
});
graph.render();

Multiple Badges

Add multiple badges at different positions to the combo:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 200,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
badge: true, // Whether to show badges
badges: [
{ text: 'A', placement: 'right-top' },
{ text: 'Important', placement: 'right' },
{ text: 'Notice', placement: 'right-bottom' },
],
badgePalette: ['#7E92B5', '#F4664A', '#FFBE3A'], // Badge background palette
badgeFontSize: 7, // Badge font size
},
},
});
graph.render();

Custom Badge Style

Fully customize badge appearance:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 200,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
badges: [
{
text: '99+',
placement: 'right-top',
backgroundFill: '#FF4D4F', // Red background
fill: '#fff', // White text
fontSize: 10,
padding: [2, 6],
backgroundRadius: 8,
},
],
},
},
});
graph.render();

Here are the complete badge style configurations:

PropertyDescriptionTypeDefault
badgeWhether to show combo badgebooleantrue
badgePaletteCombo badge background palettestring[][#7E92B5, #F4664A, #FFBE3A]
badgesCombo badge settingsBadgeStyleProps[]-

BadgeStyleProps

PropertyDescriptionTypeDefault
backgroundWhether to show combo badge backgroundbooleantrue
backgroundCursorCombo badge background cursor style, optionsstringdefault
backgroundFillCombo badge background fill color. If not specified, consider badgePalette for sequential allocationstring-
backgroundFillOpacityCombo badge background fill opacitynumber1
backgroundFilterCombo badge background filterstring-
backgroundHeightCombo badge background heightnumber | string-
backgroundLineDashCombo badge background dash configurationnumber | string |(number | string )[]-
backgroundLineDashOffsetCombo badge background dash offsetnumber-
backgroundLineWidthCombo badge background stroke line widthnumber-
backgroundRadiusCombo badge background border radius
- number: Set all four corner radius uniformly
- number[]: Set four corner radius separately, missing values will be filled
- string: Similar to CSS padding property, space-separated
number | number[] | string0
backgroundShadowBlurCombo badge background shadow blurnumber-
backgroundShadowColorCombo badge background shadow colorstring-
backgroundShadowOffsetXCombo badge background shadow X offsetnumber-
backgroundShadowOffsetYCombo badge background shadow Y offsetnumber-
backgroundStrokeCombo badge background stroke colorstring-
backgroundStrokeOpacityCombo badge background stroke opacitynumber | string1
backgroundVisibilityWhether combo badge background is visiblevisible | hidden-
fillCombo badge text colorstring-
fontFamilyCombo badge font familystring-
fontSizeCombo badge font sizenumber8
fontStyleCombo badge font stylenormal | italic | obliquenormal
fontVariantCombo badge font variantnormal | small-caps | stringnormal
fontWeightCombo badge font weightnumber | stringnormal
lineHeightCombo badge line heightstring | number-
lineWidthCombo badge line widthstring | number-
maxLinesCombo badge text maximum linesnumber1
offsetXCombo badge X offsetnumber0
offsetYCombo badge Y offsetnumber0
paddingCombo badge paddingnumber | number[]0
placementCombo badge position relative to combo main graphic. If not specified, defaults to clockwise placement starting from top-rightleft | right | top | bottom | left-top | left-bottom | right-top | right-bottom | top-left | top-right | bottom-left | bottom-right-
textCombo badge text contentstring-
textAlignCombo badge text horizontal alignmentstart | center | middle | end | left | rightleft
textBaselineCombo badge text baselinetop | hanging | middle | alphabetic | ideographic | bottomalphabetic
textDecorationColorCombo badge text decoration colorstring-
textDecorationLineCombo badge text decoration linestring-
textDecorationStyleCombo badge text decoration stylesolid | double | dotted | dashed | wavysolid
textOverflowCombo badge text overflow handlingclip | ellipsis | stringclip
visibilityWhether combo badge is visiblevisible | hidden-
wordWrapWhether combo badge text auto-wrapsboolean-
zIndexCombo badge rendering layernumber3

Halo Style

Halo effect is used to highlight combos, usually used in mouse hover, selected, or active states, adding glow effect around combos.

Basic Halo Effect

Add simple halo effect to combo:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
halo: true, // Enable halo
haloStroke: '#1783FF', // Blue halo
haloLineWidth: 8, // Halo width
haloStrokeOpacity: 0.3, // Halo opacity
},
},
});
graph.render();

Colorful Halo Effect

Create colorful gradient halo effect:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
halo: true,
haloStroke: '#FF4D4F', // Red halo
haloLineWidth: 12, // Thicker halo
haloStrokeOpacity: 0.5,
haloFilter: 'blur(2px)', // Blur filter effect
},
},
});
graph.render();

Dynamic Halo Effect

Use halo effect in state transitions:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
// No halo in default state
halo: false,
},
state: {
// Show orange halo in hover state
hover: {
halo: true,
haloStroke: '#FF7A00',
haloLineWidth: 10,
haloStrokeOpacity: 0.4,
},
// Show green halo in selected state
selected: {
halo: true,
haloStroke: '#52C41A',
haloLineWidth: 6,
haloStrokeOpacity: 0.6,
},
},
},
});
graph.render();

Here are the complete halo style configurations:

PropertyDescriptionTypeDefaultRequired
haloWhether to show combo halobooleanfalse
haloCursorCombo halo cursor style, optionsstringdefault
haloDraggableWhether combo halo allows draggingbooleantrue
haloDroppableWhether combo halo allows receiving dragged elementsbooleanfalse
haloFillHalo fill colorstringSame as main graphic fill color
haloFillRuleCombo halo fill rulenonzero | evenodd-
haloFilterCombo halo filter effect, such as 'blur(2px)' for blur effectstring-
haloLineWidthCombo halo stroke width, controls halo thicknessnumber12
haloPointerEventsWhether combo halo effect responds to pointer events, optionsstringnone
haloStrokeCombo halo stroke color, this property is used to set the color of halo around combo, helping to highlight the combostring#99add1
haloStrokeOpacityCombo halo stroke opacity, recommended to use 0.2-0.6 values for natural halo effectnumber0.25
haloVisibilityCombo halo visibilityvisible | hiddenvisible
haloZIndexCombo halo rendering layer, usually set to negative value to ensure halo is below combo main graphicnumber-1
halo{StyleProps}More halo style configurations, refer to DisplayObject options. For example, haloFillOpacity represents halo fill opacityDisplayObject-

Halo Usage Recommendations:

  1. Performance Consideration: Halo effects increase rendering burden, recommend enabling only when necessary
  2. Color Matching: Halo color should coordinate with combo main color tone, avoid being too abrupt
  3. Opacity Setting: Reasonable opacity (0.2-0.6) can create natural halo effect
  4. State Application: Halo is usually used for hover, selected, active and other interactive states

Icon Style

Icons are used to display text or image content in combos, usually located at the center of the combo, can be used to represent combo type or function.

Text Icon

Use text as combo icon:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
combos: [{ id: 'combo1' }],
},
combo: {
style: {
iconText: 'A', // Display letter A
iconFill: '#1783FF', // Blue text
iconFontSize: 24, // Large font
iconFontWeight: 'bold', // Bold
},
},
});
graph.render();

Image Icon

Use image as combo icon:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
combos: [{ id: 'combo1' }],
},
combo: {
style: {
fill: '#1890FF',
iconSrc: 'https://gw.alipayobjects.com/zos/basement_prod/012bcf4f-423b-4922-8c24-32a89f8c41ce.svg',
iconWidth: 32,
iconHeight: 32,
},
},
});
graph.render();

Colorful Text Icon

Create text icon with special styles:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 240,
height: 100,
autoFit: 'center',
data: {
combos: [{ id: 'combo1' }],
},
combo: {
style: {
iconText: 'Dept',
iconFill: '#FF4D4F', // Red text
iconFontSize: 16,
iconFontWeight: 'bold',
iconFontStyle: 'italic', // Italic
iconTextDecorationLine: 'underline', // Underline
iconLetterSpacing: 1, // Letter spacing
},
},
});
graph.render();

Here are the complete icon style configurations:

PropertyDescriptionTypeDefault
iconWhether to show combo iconbooleantrue
iconCursorCombo icon cursor style, optionsstringdefault
iconFillCombo icon text colorstring-
iconFillOpacityCombo icon text color opacitynumber1
iconFontFamilyCombo icon font familystring-
iconFontSizeCombo icon font sizenumber16
iconFontStyleCombo icon font stylenormal | italic | obliquenormal
iconFontVariantCombo icon font variantnormal | small-caps | stringnormal
iconFontWeightCombo icon font weightnumber | stringnormal
iconHeightCombo icon height, used to control image size when using image iconnumberHalf of main graphic height
iconLetterSpacingCombo icon text letter spacingnumber | string-
iconLineHeightCombo icon text line heightnumber | string-
iconMaxLinesCombo icon text maximum linesnumber1
iconOffsetXCombo icon X offsetnumber0
iconOffsetYCombo icon Y offsetnumber0
iconOpacityCombo icon opacitynumber1
iconRadiusCombo icon border radius (only effective for rectangular icons)number0
iconSrcCombo image source. Has higher priority than iconText, supports local and network imagesstring-
iconTextCombo icon text content, supports text, Unicode characters, etc.string-
iconTextAlignCombo icon text horizontal alignmentstart | center | middle | end | left | rightcenter
iconTextBaselineCombo icon text baselinetop | hanging | middle | alphabetic | ideographic | bottommiddle
iconTextDecorationColorCombo icon text decoration colorstring-
iconTextDecorationLineCombo icon text decoration line, such as underline, strikethrough, etc.string-
iconTextDecorationStyleCombo icon text decoration stylesolid | double | dotted | dashed | wavysolid
iconTextOverflowCombo icon text overflow handlingclip | ellipsis | stringclip
iconVisibilityWhether combo icon is visiblevisible | hiddenvisible
iconWidthCombo icon width, used to control image size when using image iconnumberHalf of main graphic width
iconWordWrapWhether combo icon text auto-wrapsbooleanfalse
iconZIndexCombo icon rendering layernumber1
icon{StyleProps}More icon style configurations, refer to specific icon type options. For example, iconStroke represents icon stroke color--

Icon Usage Recommendations:

  1. Priority: iconSrc (image) has higher priority than iconText (text), if both are set, image will be displayed first
  2. Size Control: Recommend setting icon size reasonably according to combo size, avoid icons being too large or small affecting visual effect
  3. Performance Optimization: Text icons have better performance, image icons require additional network requests and rendering overhead
  4. Style Consistency: Icon styles in the same graph should be consistent to improve overall visual effect
  5. Accessibility: Ensure icon color has sufficient contrast with background for easy user identification

State

In some interactive behaviors, such as clicking to select a combo or hovering to activate an edge, it is merely marking certain states on the element. To reflect these states in the visual space seen by the end user, we need to set different graphic element styles for different states to respond to changes in the element's state.

G6 provides several built-in states, including selected, highlight, active, inactive, and disabled. In addition, it also supports custom states to meet more specific needs. For each state, developers can define a set of style rules that will override the default styles of the element.

The data structure is as follows:

type ComboState = {
[state: string]: ComboStyle;
};

For example, when the combo is in the focus state, you can add a stroke with a width of 3 and a color of orange.

const graph = new Graph({
combo: {
state: {
focus: {
lineWidth: 3, // Stroke width
stroke: 'orange', // Stroke color
},
},
},
});

The effect is as follows:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 200,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1', states: ['focus'] }],
},
combo: {
state: {
focus: {
lineWidth: 3,
stroke: 'orange',
fill: 'orange',
fillOpacity: 0.2,
},
},
},
});
graph.render();

⚠️ Dynamic Configuration: State configuration also supports dynamic configuration, which can be used to set styles dynamically based on combo data:

const graph = new Graph({
combo: {
state: {
// Static configuration
selected: {
stroke: '#1783FF',
lineWidth: 2,
},
// Dynamic configuration - arrow function form
hover: (datum) => ({
fill: datum.data.isVIP ? '#FFD700' : '#1783FF',
fillOpacity: 0.3,
}),
// Dynamic configuration - regular function form (access to graph instance)
active: function (datum) {
console.log(this); // graph instance
return {
stroke: datum.data.level > 3 ? '#FF4D4F' : '#52C41A',
lineWidth: 3,
};
},
},
},
});

⚠️ State Priority: When a combo has multiple states simultaneously, the style merge follows the following priority (high to low):

  1. Later defined states override earlier defined states
  2. More specific selectors have higher priority
  3. Dynamic configuration has higher priority than static configuration

For example, if a combo has both selected and hover states, and hover is defined after selected, then hover state styles will override selected state styles.

Animation

Defines the animation effects for combos, supporting the following two configuration methods:

  1. Disable all combo animations
{
"combo": {
"animation": false
}
}
  1. Configure stage animations

Stage animations refer to animation effects when combos enter the canvas, update, or leave the canvas. Currently supported stages include:

  • enter: Animation when combo enters the canvas
  • update: Animation when combo updates
  • exit: Animation when combo leaves the canvas
  • show: Animation when combo shows from hidden state
  • hide: Animation when combo hides
  • collapse: Animation when combo collapses
  • expand: Animation when combo expands

You can refer to Animation Paradigm to use animation syntax to configure combos, such as:

Enter Animation

Configure animation when combo enters the canvas:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 200,
height: 100,
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
animation: {
enter: [
{
fields: ['opacity'], // Animate opacity property
from: 0, // Start from 0
to: 1, // End at 1
duration: 1000, // Animation duration
easing: 'ease-out', // Easing function
},
],
},
},
});
graph.render();

Update Animation

Configure animation when combo updates:

const graph = new Graph({
combo: {
animation: {
update: [
{
fields: ['x', 'y'], // Only animate x and y properties during update
duration: 1000, // Animation duration
easing: 'linear', // Easing function
},
],
},
},
});

Exit Animation

Configure animation when combo leaves the canvas:

const graph = new Graph({
combo: {
animation: {
exit: [
{
fields: ['opacity'], // Animate opacity property
to: 0, // End at 0
duration: 500, // Animation duration
easing: 'ease-in', // Easing function
},
],
},
},
});

Show/Hide Animation

Configure animation when combo shows/hides:

const graph = new Graph({
combo: {
animation: {
show: [
{
fields: ['opacity'],
from: 0,
to: 1,
duration: 300,
},
],
hide: [
{
fields: ['opacity'],
to: 0,
duration: 300,
},
],
},
},
});

You can also use built-in animation effects:

{
"combo": {
"animation": {
"enter": "fade", // Use fade animation
"update": "translate", // Use translate animation
"exit": "fade" // Use fade animation
}
}
}

You can pass false to disable specific stage animations:

{
"combo": {
"animation": {
"enter": false // Disable combo enter animation
}
}
}

Animation Configuration Options:

PropertyDescriptionTypeDefault
fieldsProperties to animatestring[]-
fromStarting valuenumber | string-
toEnding valuenumber | string-
durationAnimation duration (milliseconds)number1000
easingEasing functionstring'ease'
delayAnimation delay (milliseconds)number0
repeatNumber of repetitions (-1 for infinite)number0
directionAnimation direction'normal' | 'reverse' | 'alternate' | 'alternate-reverse''normal'

Palette

Defines combo color palette, i.e., predefined combo color pool, and allocates according to rules, mapping colors to the fill property.

For palette definition, please refer to Palette.

PropertyDescriptionTypeDefault
typeSpecifies current palette type.
- group: Discrete palette
- value: Continuous palette
group | valuegroup
fieldSpecifies grouping field in element data. If not specified, defaults to id as grouping fieldstring | ((datum) => string)id
colorPalette colors. If palette is registered, you can directly specify its registration name, also accepts a color arraystring | string[]-
invertWhether to invert the palettebooleanfalse

For example, assign combo colors to a group of data by category field, so that combos of the same category have the same color:

{
"combo": {
"palette": {
"type": "group",
"field": "category",
"color": ["#1783FF", "#F08F56", "#D580FF", "#00C9C9", "#7863FF"]
}
}
}

The effect is as follows:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 600,
height: 100,
data: {
combos: new Array(8)
.fill(0)
.map((_, i) => ({ id: `combo-${i}`, data: { category: ['A', 'B', 'C', 'D', 'E'][i % 5] } })),
},
layout: { type: 'grid', cols: 8 },
combo: {
style: { fillOpacity: 0.4 },
palette: {
type: 'group',
field: 'category',
color: ['#1783FF', '#F08F56', '#D580FF', '#00C9C9', '#7863FF'],
},
},
});
graph.render();

You can also use default configuration:

{
"combo": {
"palette": "tableau" // tableau is palette name, defaults to assign colors by ID
}
}

The effect is as follows:

import { Graph } from '@antv/g6';
const graph = new Graph({
container: 'container',
width: 600,
height: 100,
data: {
combos: new Array(8)
.fill(0)
.map((_, i) => ({ id: `combo-${i}`, data: { category: ['A', 'B', 'C', 'D', 'E'][i % 5] } })),
},
layout: { type: 'grid', cols: 8 },
combo: {
style: { fillOpacity: 0.4 },
palette: 'tableau',
},
});
graph.render();