logo

G2

  • Chart Gallery
  • Docs
  • Examples
  • Theme
  • Ecosystem
  • Productsantv logo arrow
  • 5.3.3
  • Get Started
  • Introduction
    • What is G2
    • Using in Frontend Frameworks
    • Experimental Spec API
  • Chart API
  • Core Concepts
    • Chart
      • Components of G2 Charts
      • How to Use Charts
    • Mark
      • Overview
      • area
      • box
      • boxplot
      • cell
      • chord
      • density
      • gauge
      • heatmap
      • image
      • interval
      • line
      • lineX
      • lineY
      • link
      • liquid
      • sunburst
      • point
      • polygon
      • range
      • rangeX
      • rangeY
      • rect
      • shape
      • text
      • vector
      • connector
      • wordCloud
    • View
    • Data
      • Overview
      • custom
      • ema
      • fetch
      • filter
      • fold
      • inline
      • join
      • kde
      • log
      • map
      • pick
      • rename
      • slice
      • sort
      • sortBy
    • Encode
    • Scale
      • Overview
      • band
      • linear
      • log
      • ordinal
      • point
      • quantile
      • quantize
      • sqrt
      • threshold
      • time
      • pow
    • Transform
      • Overview
      • bin
      • binX
      • diffY
      • dodgeX
      • flexX
      • group
      • groupColor
      • groupX
      • groupY
      • jitter
      • jitterX
      • jitterY
      • normalizeY
      • pack
      • sample
      • select
      • selectX
      • selectY
      • sortColor
      • sortX
      • sortY
      • stackEnter
      • stackY
      • symmetryY
    • Coordinate
      • Overview
      • fisheye
      • parallel
      • polar
      • theta
      • transpose
      • radial
      • cartesian3D
      • helix
    • Style
    • Animate
      • Overview
      • fadeIn
      • fadeOut
      • growInX
      • growInY
      • morphing
      • pathIn
      • scaleInX
      • scaleInY
      • scaleOutX
      • scaleOutY
      • waveIn
      • zoomIn
      • zoomOut
    • State
    • Interaction
      • Overview
      • brushAxisHighlight
      • brushHighlight
      • brushXHighlight
      • brushYHighlight
      • brushFilter
      • brushXFilter
      • brushYFilter
      • chartIndex
      • elementHighlight
      • elementHighlightByColor
      • elementHighlightByX
      • elementSelect
      • elementSelectByColor
      • elementSelectByX
      • legendFilter
      • legendHighlight
      • poptip
      • scrollbarFilter
      • sliderFilter
      • fisheye
    • Composition
      • Overview
      • facetCircle
      • facetRect
      • repeatMatrix
      • spaceFlex
      • spaceLayer
      • timingKeyframe
    • Theme
      • Overview
      • academy
      • classic
      • classicDark
    • Events
    • Color Mapping
  • Chart Component
    • Title
    • Axis
    • Legend
    • Scrollbar
    • Slider
    • Tooltip
    • Data Label
  • Extra Topics
    • Graph
      • forceGraph
      • pack
      • sankey
      • tree
      • treemap
    • Geo
      • geoPath
      • geoView
    • 3D
      • Draw 3D Chart
      • point3D
      • line3D
      • interval3D
      • surface3D
    • Plugin
      • renderer
      • rough
      • lottie
      • a11y
    • Package on demand
    • Set pattern
    • Server-Side Rendering (SSR)
    • Spec Function Expression Support (Available in 5.3.0)
  • Whats New
    • New Version Features
    • Migration from v4 to v5
  • Frequently Asked Questions (FAQ)

chord

Previous
cell
Next
density

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

chord is a circular chart used to visualize matrix relationship data, intuitively displaying bidirectional flows or connection strengths between different categories through node arcs arranged around the circumference and interconnected ribbon curves. In chord, data points (nodes) are typically arranged along a circular ring, with chords (curves) connecting relationships or flows between nodes. Each chord not only represents the connection between two nodes but can also express the weight or strength of relationships through visual channels (such as color, width, transparency, etc.). Chord charts are widely used in scenarios such as social networks, system call relationships, traffic distribution, and transaction flow analysis. By clearly displaying complex connections between nodes, they help users quickly understand structures and patterns in data.

import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
});
chart.options({
type: 'chord',
layout: { nodeWidthRatio: 0.05 },
data: {
value: {
links: [
{ source: 'Beijing', target: 'Tianjin', value: 30 },
{ source: 'Beijing', target: 'Shanghai', value: 80 },
{ source: 'Beijing', target: 'Hebei', value: 46 },
{ source: 'Beijing', target: 'Liaoning', value: 49 },
{ source: 'Beijing', target: 'Heilongjiang', value: 69 },
{ source: 'Beijing', target: 'Jilin', value: 19 },
{ source: 'Tianjin', target: 'Hebei', value: 62 },
{ source: 'Tianjin', target: 'Liaoning', value: 82 },
{ source: 'Tianjin', target: 'Shanghai', value: 16 },
{ source: 'Shanghai', target: 'Heilongjiang', value: 16 },
{ source: 'Hebei', target: 'Heilongjiang', value: 76 },
{ source: 'Hebei', target: 'Inner Mongolia', value: 24 },
{ source: 'Inner Mongolia', target: 'Beijing', value: 32 },
],
},
},
scale: {
color: {
range: [
'#4e79a7',
'#f28e2c',
'#e15759',
'#76b7b2',
'#59a14f',
'#edc949',
'#af7aa1',
'#ff9da7',
'#9c755f',
'#bab0ab',
],
},
},
style: { labelFontSize: 15, linkFillOpacity: 0.6 },
});
chart.render();

Configuration Options

PropertyDescriptionTypeDefaultRequired
encodeConfigure visual channels for chord marks, including color, shape, etc., to specify relationships between visual attributes and dataencode-
layoutConfigure chord layout methodlayout-
scaleConfigure scale for chord marks, including x, y, color, shape, etc.scale{x: { type: 'identity' },y: { type: 'identity' }}
styleConfigure chord graphic stylesstyle-

encode

PropertyDescriptionTypeDefault
colorMap colors of nodes or connecting chords, used to distinguish different categories or relationship strengthsencode-
nodeShapeShape of nodes in the chord diagram, defining the specific visual appearance of nodesstring| Function<string>polygon
linkShapeShape of connecting chords in the chord diagram, defining the specific visual appearance of chordsstring| Function<string>ribbon
sourceDefine the starting point of connecting chords, usually mapped to a node fieldstring| Function<string>source
targetDefine the ending point of connecting chords, usually mapped to another node fieldstring| Function<string>target

source/target

The source and target visual channels are important properties that affect the starting and ending points of connecting chords in chord chart marks. source maps to the field in data representing the starting node of connection relationships, while target maps to the field representing the ending node of connection relationships. These two properties together build the relationship logic between nodes in the chord diagram, visually representing interactions or dependencies between nodes through intuitive connecting chords.

import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
});
chart.options({
type: 'chord',
data: {
value: {
links: [
{ begin: 'Beijing', end: 'Tianjin', value: 34 },
{ begin: 'Beijing', end: 'Shanghai', value: 95 },
{ begin: 'Beijing', end: 'Hebei', value: 61 },
{ begin: 'Beijing', end: 'Liaoning', value: 32 },
{ begin: 'Beijing', end: 'Heilongjiang', value: 84 },
{ begin: 'Beijing', end: 'Jilin', value: 19 },
{ begin: 'Tianjin', end: 'Hebei', value: 62 },
{ begin: 'Tianjin', end: 'Liaoning', value: 34 },
{ begin: 'Tianjin', end: 'Shanghai', value: 48 },
{ begin: 'Shanghai', end: 'Heilongjiang', value: 67 },
{ begin: 'Hebei', end: 'Heilongjiang', value: 37 },
{ begin: 'Hebei', end: 'Inner Mongolia', value: 51 },
{ begin: 'Inner Mongolia', end: 'Beijing', value: 56 },
],
},
},
encode: {
source: 'begin',
target: 'end',
},
});
chart.render();

Encode properties like source and target also support dynamically retrieving values from data. You can pass a function, and the chart will call this function during execution to calculate the required results.

import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
});
chart.options({
type: 'chord',
data: {
value: {
links: [
{ begin: 'Beijing', end: 'Tianjin', value1: 34, value2: 46 },
{ begin: 'Beijing', end: 'Shanghai', value1: 95, value2: 69 },
{ begin: 'Beijing', end: 'Hebei', value1: 61, value2: 62 },
{ begin: 'Beijing', end: 'Liaoning', value1: 32, value2: 82 },
{ begin: 'Beijing', end: 'Heilongjiang', value1: 84, value2: 30 },
{ begin: 'Beijing', end: 'Jilin', value1: 19, value2: 1 },
{ begin: 'Tianjin', end: 'Hebei', value1: 62, value2: 24 },
{ begin: 'Tianjin', end: 'Liaoning', value1: 34, value2: 16 },
{ begin: 'Tianjin', end: 'Shanghai', value1: 48, value2: 49 },
{ begin: 'Shanghai', end: 'Heilongjiang', value1: 67, value2: 80 },
{ begin: 'Hebei', end: 'Heilongjiang', value1: 37, value2: 67 },
{ begin: 'Hebei', end: 'Inner Mongolia', value1: 51, value2: 16 },
{ begin: 'Inner Mongolia', end: 'Beijing', value1: 56, value2: 76 },
],
},
},
encode: {
source: (d) => d.begin,
target: (d) => d.end,
},
});
chart.render();

For more encode configurations, please refer to the encode introduction page.

layout

The layout property controls the layout method of chord diagrams, defining how nodes and connecting chords are presented on the canvas. Chord diagram layouts are typically based on circular (ring) arrangements, distributing all nodes evenly around the circumference and displaying relationships and weights between nodes through connecting chords. Through layout configuration, you can further adjust node positions, connection methods, and graphic structures.

PropertyDescriptionTypeDefault
yY-axis coordinate during layoutnumber0
idKey of the nodeFunction<string | number>(node) => node.key
sourceSet the source node data field for the chord diagramFunction<string>(edge) => edge.source
targetSet the target node data field for the chord diagramFunction<string>(edge) => edge.target
sourceWeightWeight of the sourceFunction<number>(edge) => edge.value | 1
targetWeightWeight of the targetFunction<number>(edge) => edge.value | 1
sortBySorting method, can choose id, weight, frequency sorting or custom sorting methodstring | Function<number>null
nodeWidthRatioWidth configuration of chord diagram nodes, 0 ~ 1, relative to canvas widthnumber0.05
nodePaddingRatioSpacing between chord diagram nodes, 0 ~ 1, relative to canvas heightnumber0.1

scale

The scale property defines how data fields map to visual properties of graphics (such as node positions, chord lengths, colors, etc.), thus affecting the presentation of chord diagrams. By configuring scale, you can adjust node arrangement order, connection chord weight proportions, or color mappings to make charts better conform to data characteristics or user analysis needs.

PropertyDescriptionTypeDefault
xDefine the arrangement position of nodes on the circumference, can map to categorical or numerical fieldsRecord<string, scale>{ type: 'identity' }
yControl the projection position of nodes or chords, usually not explicitly set in chord diagramsRecord<string, scale>{ type: 'identity' }
colorDefine color mapping rules for nodes or connecting chords, used to distinguish different categories or relationship strengthsRecord<string, scale>-
sizeMap the thickness of connecting chords or size of nodes to represent weight or strengthRecord<string, scale>-

For more scale configurations, please refer to the scale introduction page.

style

The style property provides a series of configuration options for customizing the visual effects of chord diagrams, mainly affecting nodes, links (connecting chords), and labels.

PropertyDescriptionTypeDefault
linkFillOpacityFill opacity of connecting chords (relationship lines connecting different nodes) in chord graphicsnumber | Function<number>1
linkFillFill color of connecting chords (relationship lines connecting different nodes) in chord graphicsstring | Function<number>-
linkStrokeBorder color of connecting chords in chord graphicsstring | Function<number>-
linkOpacityOverall opacity of connecting chords in chord graphics (including fill and border)number | Function<number>0.5
linkLineDashDashed line style for connecting chord borders in chord graphics[number, number]-
labelFillFont color of node labels in chord graphicsstring | Function<number>-
labelFillOpacityTransparency of node label font color in chord graphicsnumber | Function<number>0.6
labelFontSizeFont size of node labels in chord graphicsnumber | Function<number>10
labelFontWeightFont weight of node labels in chord graphics (such as "normal", "bold")string| numbernormal
labelOpacityOverall opacity of node labels in chord graphicsnumber | Function<number>1
nodeFillFill color of nodes in chord graphicsstring | Function<number>-
nodeFillOpacityFill opacity of nodes in chord graphicsnumber | Function<number>1
nodeStrokeBorder color of nodes in chord graphicsstring | Function<number>-
nodeOpacityOverall opacity of nodes in chord graphicsnumber | Function<number>1
nodeLineDashDashed line style for node borders in chord graphics[number, number]-
cursorMouse cursor style. Same as CSS cursor style, default 'default'.string | Function<number>'default'

For more style configurations, please refer to the style introduction page.

Try it out: