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

Atomic Shapes and Their Properties

Previous
Shape and KeyShape
Next
Design and Implementation of Composite Shape

Resource

Ant Design
Galacea Effects
Umi-React Application Framework
Dumi-Component doc generator
ahooks-React Hooks Library
WeaveFox-AI Coding Assistant

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference
weavefoxWeaveFox-AI Developer Community

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
weavefoxWeaveFox-AI Coding Assistant
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

Elements (nodes/edges) in G6 are composed of one or more shapes, mainly added via upsert in the render method when customizing nodes or edges. G6 supports the following shapes:

  1. Circle
  2. Ellipse
  3. Rect
  4. HTML Element
  5. Image
  6. Line
  7. Path
  8. Polygon
  9. Polyline
  10. Text

Common Properties of All Shapes

BaseShapeStyle

PropertyDescriptionTypeRequired
xx coordinatenumber✓
yy coordinatenumber✓
widthWidthnumber✓
heightHeightnumber✓
fillFill colorstring | Pattern | null
strokeStroke colorstring | Pattern | null
opacityOverall opacitynumber | string
fillOpacityFill opacitynumber | string
strokeOpacityStroke opacitynumber | string
lineWidthLine widthnumber | string
lineCapLine cap stylebutt | round | square
lineJoinLine join stylemiter | round | bevel
lineDashDash arraynumber | string | (string | number)[]
lineDashOffsetDash offsetnumber
shadowBlurShadow blurnumber
shadowColorShadow colorstring
shadowOffsetXShadow X offsetnumber
shadowOffsetYShadow Y offsetnumber
cursorMouse cursor, supports all CSS cursorstring
zIndexRender z-indexnumber
visibilityVisibilityvisible | hidden

Example:

const shape = BaseShape.upsert(
// Specify the shape key, which must be unique within the same custom element type
'shape',
'circle',
{
cx: 100,
cy: 100,
r: 50,
fill: 'blue',
},
container,
);

Common Methods of All Shapes

attr()

Set or get the drawing attributes of the instance.

attr(name)

Get the value of an attribute.

const width = shape.attr('width');

attr(name, value)

Update a single drawing attribute.

attr({...})

Batch update drawing attributes.

shape.attr({
fill: '#999',
stroke: '#666',
});

Circle Shape

CircleStyleProps

PropertyDescriptionTypeRequired
cxCenter x coordinatenumber | string✓
cyCenter y coordinatenumber | string✓
czCenter z coordinatenumber | string
rRadiusnumber | string✓
isBillboardBillboard mode (always faces camera)boolean
isSizeAttenuationSize attenuation (size changes with view)boolean

Example:

BaseShape.upsert(
'shape',
'circle',
{
cx: 100,
cy: 100,
r: 50,
fill: 'blue',
},
container,
);

Rect Shape

RectStyleProps

PropertyDescriptionTypeRequired
xRect x coordinatenumber | string
yRect y coordinatenumber | string
zRect z coordinatenumber
widthRect widthnumber | string✓
heightRect heightnumber | string✓
isBillboardBillboard modeboolean
isSizeAttenuationSize attenuationboolean
radiusBorder radiusnumber | string | number[]

Example:

BaseShape.upsert(
'shape',
'rect',
{
x: 100,
y: 100,
width: 100,
height: 100,
radius: 8,
fill: 'blue',
},
container,
);

Ellipse Shape

EllipseStyleProps

PropertyDescriptionTypeRequired
cxCenter x coordinatenumber | string✓
cyCenter y coordinatenumber | string✓
czCenter z coordinatenumber | string
rxX-axis radiusnumber | string✓
ryY-axis radiusnumber | string✓
isBillboardBillboard modeboolean
isSizeAttenuationSize attenuationboolean

Example:

BaseShape.upsert(
'shape',
'ellipse',
{
cx: 100,
cy: 100,
rx: 50,
ry: 80,
fill: 'blue',
},
container,
);

HTML DOM

HTMLStyleProps

PropertyDescriptionTypeRequired
xHTML x coordinatenumber | string
yHTML y coordinatenumber | string
innerHTMLHTML contentstring | HTMLElement✓
widthHTML widthnumber | string
heightHTML heightnumber | string

Example:

BaseShape.upsert(
'shape',
'html',
{
x: 100,
y: 100,
innerHTML: <div>content</div>,
},
container,
);

Image Shape

ImageStyleProps

PropertyDescriptionTypeRequired
xImage x coordinatenumber | string
yImage y coordinatenumber | string
zImage z coordinatenumber
srcImage source or HTMLImageElementstring | HTMLImageElement✓
widthImage widthnumber | string
heightImage heightnumber | string
isBillboardBillboard modeboolean
isSizeAttenuationSize attenuationboolean
billboardRotationBillboard rotation anglenumber
keepAspectRatioKeep original aspect ratioboolean

Example:

BaseShape.upsert(
'shape',
'image',
{
x: 100,
y: 100,
src: 'http://',
},
container,
);

Line Shape

LineStyleProps

PropertyDescriptionTypeRequired
x1Start x coordinatenumber✓
y1Start y coordinatenumber✓
x2End x coordinatenumber✓
y2End y coordinatenumber✓
z1Start z coordinatenumber
z2End z coordinatenumber
isBillboardBillboard modeboolean
isSizeAttenuationSize attenuationboolean
markerStartMarker at startDisplayObject | null
markerEndMarker at endDisplayObject | null
markerStartOffsetStart marker offsetnumber
markerEndOffsetEnd marker offsetnumber

Example:

BaseShape.upsert(
'shape',
'line',
{
x1: 100,
y1: 100,
x2: 150,
y2: 150,
stroke: 'blue',
},
container,
);

Path Shape

PathStyleProps

PropertyDescriptionTypeRequired
dPath string or arraystring | PathArray✓
markerStartMarker at startDisplayObject | null
markerEndMarker at endDisplayObject | null
markerMidMarker at middleDisplayObject | null
markerStartOffsetStart marker offsetnumber
markerEndOffsetEnd marker offsetnumber
isBillboardBillboard modeboolean
isSizeAttenuationSize attenuationboolean
fillRuleFill rulenonzero | evenodd

Example:

BaseShape.upsert(
'shape',
'path',
{
d: 'M 0,0 L 20,10 L 20,-10 Z',
stroke: 'blue',
},
container,
);

Polygon Shape

PolygonStyleProps

PropertyDescriptionTypeRequired
pointsArray of polygon points([number, number] | [number, number, number])[]✓
markerStartMarker at startDisplayObject | null
markerEndMarker at endDisplayObject | null
markerMidMarker at middleDisplayObject | null
markerStartOffsetStart marker offsetnumber
markerEndOffsetEnd marker offsetnumber
isClosedIs polygon closedboolean
isBillboardBillboard modeboolean
isSizeAttenuationSize attenuationboolean

Example:

BaseShape.upsert(
'shape',
'polygon',
{
points: [
[30, 30],
[40, 20],
[30, 50],
[60, 100],
],
fill: 'red',
},
container,
);

Polyline Shape

PolylineStyleProps

PropertyDescriptionTypeRequired
pointsArray of polyline points([number, number] | [number, number, number])[]✓
markerStartMarker at startDisplayObject | null
markerEndMarker at endDisplayObject | null
markerMidMarker at middleDisplayObject | null
markerStartOffsetStart marker offsetnumber
markerEndOffsetEnd marker offsetnumber
isBillboardBillboard modeboolean
isSizeAttenuationSize attenuationboolean

Example:

BaseShape.upsert(
'shape',
'polyline',
{
points: [
[30, 30],
[40, 20],
[30, 50],
[60, 100],
],
fill: 'red',
},
container,
);

Text

TextStyleProps

PropertyDescriptionTypeRequired
xText x coordinatenumber | string
yText y coordinatenumber | string
zText z coordinatenumber | string
textText contentnumber | string✓
fontSizeFont sizenumber | string
fontFamilyFont familystring
fontStyleFont stylenormal | italic | oblique
fontWeightFont weightnormal | bold | bolder | lighter | number
fontVariantFont variantnormal | small-caps | string
textAlignText horizontal alignstart | center | middle | end | left | right
textBaselineText baselinetop | hanging | middle | alphabetic | ideographic | `bottom'
textOverflowText overflowclip | ellipsis | string
lineHeightLine heightnumber | string
letterSpacingLetter spacingnumber | string
maxLinesMax linesnumber
textPathText pathPath
textPathSideText path sideleft | right
textPathStartOffsetText path start offsetnumber | string
textDecorationLineText decoration linestring
textDecorationColorText decoration colorstring
textDecorationStyleText decoration stylesolid | double | dotted | dashed | wavy
isBillboardBillboard modeboolean
billboardRotationBillboard rotation anglenumber
isSizeAttenuationSize attenuationboolean
wordWrapWord wrapboolean
wordWrapWidthWord wrap widthnumber
dxX offsetnumber | string
dyY offsetnumber | string

Example:

BaseShape.upsert(
'shape',
'text',
{
x: 100,
y: 100,
text: 'text',
},
container,
);

Display in multiply line:

{
wordWrap: true,
wordWrapWidth: 100,
maxLines: 4,
textOverflow: 'ellipsis',
}