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

Combo Configuration Options

Previous
Circle
Next
Rect

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

This document introduces combo attribute configuration, with configuration locations as follows:

import { Graph } from '@antv/g6';
const graph = new Graph({
// Other configurations...
combo: {
type: 'circle', // Combo type
style: {}, // Combo style
state: {}, // State style
palette: {}, // Palette configuration
animation: {}, // Animation configuration
},
});

ComboOptions

AttributeDescriptionTypeDefaultRequired
typeCombo type, name of built-in combo type or custom combo nameTypecircle
styleCombo style, including color, size, etc.Style-
stateDefines the style of the combo in different statesState-
paletteDefines the palette of the combo, used to map colors based on different dataPalette-
animationDefines the animation effects of the comboAnimation-

Type

Specifies the combo type, name of built-in combo type or custom combo name. The default is circle (circular combo).

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

Optional values are:

  • circle: Circular Combo
  • rect: Rectangular Combo

Style

Define the style of the combo here, including color, size, etc.

const graph = new Graph({
// Other configurations...
combo: {
style: {},
},
});
  • key: The main graphic of the combo, representing the main shape of the combo, such as a circle, rectangle, etc.
  • halo: A graphic that displays a halo effect around the main graphic.
  • label: Text label, usually used to display the name or description of the combo.

The following style configurations will be explained in sequence according to atomic graphics:

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 levelnumber0
{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:

createGraph(
{
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: { fill: '#1783FF', stroke: '#000', lineWidth: 2 },
},
},
{ width: 240, height: 100 },
);

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:

createGraph(
{
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1', style: { collapsed: true } }],
},
combo: {
style: { collapsedFill: '#1783FF', collapsedStroke: '#000', collapsedLineWidth: 2 },
},
},
{ width: 240, height: 100 },
);

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 levelnumber1
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:

createGraph(
{
autoFit: 'center',
data: {
nodes: [
{ id: 'node1', combo: 'combo1' },
{ id: 'node2', combo: 'combo1' },
],
combos: [{ id: 'combo1', style: { collapsed: true } }],
},
combo: {
style: {
collapsedMarkerFill: '#1783FF',
collapsedMarkerFontSize: 30,
},
},
},
{ width: 240, height: 100 },
);

Label Style

Labels are used to display the text information of the combo:

AttributeDescriptionTypeDefaultRequired
labelWhether to display the combo labelbooleantrue
labelCursorMouse hover style when hovering over the combo label, configuration itemstringdefault
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-
labelMaxLinesMaximum number of lines for the combo labelnumber1
labelMaxWidthMaximum width of the combo label, configuration itemnumber  string200%
labelOffsetXOffset of the combo label in the x-axis directionnumber0
labelOffsetYOffset of the combo label in the y-axis directionnumber0
labelPaddingCombo label paddingnumber  number[]0
labelPlacementPosition of the combo label relative to the main graphic of the combo, configuration itemstringbottom
labelTextCombo label text contentstring-
labelTextAlignCombo label text horizontal alignmentstart  center  middle  end  left  right'  left`
labelTextBaselineCombo label text baselinetop  hanging  middle  alphabetic  ideographic  bottom-
labelTextDecorationColorCombo label text decoration line colorstring-
labelTextDecorationLineCombo label text decoration linestring-
labelTextDecorationStyleCombo label text decoration line stylesolid  double  dotted  dashed  wavy-
labelTextOverflowCombo label text overflow handlingclip  ellipsis  string-
labelTextPathCombo label text pathPath-
labelWordWrapWhether the combo label enables automatic line wrapping. After enabling labelWordWrap, the part that exceeds labelMaxWidth will automatically wrapbooleanfalse
labelZIndexCombo label rendering levelnumber0
label{StyleProps}More label style configurations, refer to TextStyleProps attribute values. For example, labelOpacity represents label opacityTextStyleProps-

LabelPlacement

Optional values are: left | right | top | bottom | left-top | left-bottom | right-top | right-bottom | top-left | top-right | bottom-left | bottom-right | center | bottom

LabelMaxWidth

After enabling automatic line wrapping labelWordWrap, it will wrap if it exceeds this width:

  • string: Indicates the maximum width defined as a percentage of the combo element width. For example, 50% means the label width does not exceed half of the combo width
  • number: Indicates the maximum width defined in pixels. For example, 100 means the maximum width of the label is 100 pixels

For example, set multi-line label text:

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

Example:

const graph = new Graph({
// Other configurations
combo: {
style: {
label: true, // Whether to display the combo label
labelText: 'Combo Name', // Label text content
labelFill: '#000', // Label text color
labelFontSize: 12, // Label font size
labelFontWeight: 'normal', // Label font weight
labelPlacement: 'bottom', // Position of the label relative to the main graphic of the combo
},
},
});

The effect is as follows:

createGraph(
{
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [
{
id: 'combo1',
style: {
label: true,
labelText: 'Combo Name',
labelFill: '#000',
labelFontSize: 12,
labelFontWeight: 'normal',
labelPlacement: 'bottom',
},
},
],
},
},
{ width: 240, height: 100 },
);

Label Background Style

Label background is used to display the background of the combo label:

AttributeDescriptionTypeDefault
labelBackgroundWhether to display the combo label backgroundbooleanfalse
labelBackgroundCursorMouse hover style for the combo label background, configuration itemstringdefault
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 widthnumber-
labelBackgroundPaddingCombo label background paddingnumber  number[][2, 4, 2, 4]
labelBackgroundRadiusCombo label background corner radius
- number: Uniformly set the four corner radii
- number[]: Set the four corner radii separately, automatically fill in if insufficient
number  number[]0
labelBackgroundShadowBlurCombo label background shadow blurnumber-
labelBackgroundShadowColorCombo label background shadow colorstring-
labelBackgroundShadowOffsetXCombo label background shadow X direction offsetnumber-
labelBackgroundShadowOffsetYCombo label background shadow Y direction offsetnumber-
labelBackgroundStrokeCombo label background stroke colorstring-
labelBackgroundStrokeOpacityCombo label background stroke opacitynumber  string1
labelBackgroundVisibilityWhether the combo label background is visiblevisible  hidden-
labelBackgroundZIndexCombo label background rendering levelnumber1
labelBackground{StyleProps}More label background style configurations, refer to RectStyleProps attribute values. For example, labelBackgroundOpacity represents label background opacityRectStyleProps-

Example:

const graph = new Graph({
// Other configurations...
combo: {
style: {
labelBackground: true, // Whether to display the combo label background
labelBackgroundFill: '#000', // Label background fill
labelBackgroundRadius: 10, // Label background corner radius
labelBackgroundFillOpacity: 0.5, // Label background fill color opacity
},
},
});

The effect is as follows:

createGraph(
{
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [
{
id: 'combo1',
style: {
label: true,
labelText: 'Combo Name',
labelFill: '#000',
labelFontSize: 12,
labelFontWeight: 'normal',
labelPlacement: 'bottom',
labelBackground: true,
labelBackgroundFill: '#000',
labelBackgroundRadius: 10,
labelBackgroundFillOpacity: 0.5,
},
},
],
},
},
{ width: 240, height: 100 },
);

Halo Style

AttributeDescriptionTypeDefaultRequired
haloWhether to display the combo halobooleanfalse
haloCursorMouse hover style for the combo halo, configuration itemstringdefault
haloDraggableWhether the combo halo is draggablebooleantrue
haloDroppableWhether the combo halo can receive dragged elementsbooleanfalse
haloFillHalo fill colorstringSame as the fill color of the main graphic fill
haloFillRuleCombo halo fill rulenonzero  evenodd-
haloFilterCombo halo filterstring-
haloLineWidthCombo halo stroke widthnumber12
haloPointerEventsWhether the combo halo effect responds to pointer events, configuration itemstringnone
haloStrokeCombo halo stroke color, this attribute is used to set the color of the halo around the combo to help highlight the combostring#99add1
haloStrokeOpacityCombo halo stroke color opacitynumber0.25
haloVisibilityCombo halo visibilityvisible  hiddenvisible
haloZIndexCombo halo rendering levelnumber-1
halo{StyleProps}More halo style configurations, refer to DisplayObject configuration items. For example, haloFillOpacity represents halo fill color opacityDisplayObject-

PointerEvents

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

Example:

const graph = new Graph({
// Other configurations...
combo: {
style: {
halo: true, // Whether to display the combo halo
haloStroke: '#FF0000', // Combo halo stroke color
haloLineWidth: 10, // Combo halo stroke width
},
},
});

The effect is as follows:

createGraph(
{
autoFit: 'center',
data: {
nodes: [{ id: 'node1', combo: 'combo1' }],
combos: [{ id: 'combo1' }],
},
combo: {
style: {
halo: true,
haloStroke: '#FF0000',
haloLineWidth: 10,
},
},
},
{ width: 240, height: 100 },
);

Icon Style

AttributeDescriptionTypeDefault
iconWhether to display the combo iconbooleantrue
iconFillCombo icon text colorstring-
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 heightnumberHalf the height of the main graphic
iconLetterSpacingCombo icon text letter spacingnumber  string-
iconLineHeightCombo icon text line heightnumber  string-
iconMaxLinesMaximum number of lines for the combo icon textnumber1
iconRadiusCombo icon corner radiusnumber0
iconSrcCombo image source. Its priority is higher than iconTextstring-
iconTextCombo icon textstring-
iconTextAlignCombo icon text horizontal alignmentstart  center  middle  end  left  rightleft
iconTextBaselineCombo icon text baselinetop  hanging  middle  alphabetic  ideographic  bottomalphabetic
iconTextDecorationColorCombo icon text decoration line colorstring-
iconTextDecorationLineCombo icon text decoration linestring-
iconTextDecorationStyleCombo icon text decoration line stylesolid  double  dotted  dashed  wavysolid
iconTextOverflowCombo icon text overflow handlingclip  ellipsis  stringclip
iconWidthCombo icon widthnumberHalf the width of the main graphic
iconWordWrapWhether the combo icon text automatically wrapsboolean-

Example:

const graph = new Graph({
// Other configurations...
combo: {
style: {
iconText: 'Text', // Icon text
iconFill: '#FF0000', // Icon text color
iconFontSize: 14, // Icon text size
iconFontWeight: 'bold', // Icon text weight
iconFontStyle: 'italic', // Icon text style
},
},
});

The effect is as follows:

createGraph(
{
autoFit: 'center',
data: {
combos: [{ id: 'combo1' }],
},
combo: {
style: {
iconText: 'Text',
iconFill: '#FF0000',
iconFontSize: 14,
iconFontWeight: 'bold',
iconFontStyle: 'italic',
},
},
},
{ width: 240, height: 100 },
);

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:

createGraph(
{
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,
},
},
},
},
{ width: 200, height: 100 },
);

Animation

Defines the animation effects of the combo, supporting the following two configuration methods:

  1. Turn off all animations for the combo
{
"combo": {
"animation": false
}
}
  1. Configure stage animations

Stage animations refer to the animation effects of the combo when entering the canvas, updating, and leaving the canvas. The currently supported stages include:

  • enter: Animation when the combo enters the canvas
  • update: Animation when the combo is updated
  • exit: Animation when the combo leaves the canvas
  • show: Animation when the combo is displayed from a hidden state
  • hide: Animation when the combo is hidden
  • collapse: Animation when the combo is collapsed
  • expand: Animation when the combo is expanded

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

{
"combo": {
"animation": {
"update": [
{
"fields": ["x", "y"], // Only animate the x and y attributes during update
"duration": 1000, // Animation duration
"easing": "linear" // Easing function
}
],
}
}

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 in false to turn off animations for specific stages:

{
"combo": {
"animation": {
"enter": false // Turn off combo entrance animation
}
}
}

Palette

Defines the palette of the combo, which is a predefined pool of combo colors, and assigns colors based on rules, mapping colors to the fill attribute.

For the definition of the palette, please refer to Palette.

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

For example, assign combo colors to a set of data based on the 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:

createGraph(
{
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'],
},
},
},
{ width: 600, height: 100 },
);

You can also use the default configuration:

{
"combo": {
"palette": "tableau" // tableau is the palette name, and colors are assigned based on ID by default
}
}

The effect is as follows:

createGraph(
{
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',
},
},
{ width: 600, height: 100 },
);