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)

sunburst

Previous
liquid
Next
point

Resources

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

Community

Ant Financial Experience Tech
seeconfSEE Conf-Experience Tech Conference

Help

GitHub
StackOverflow

more productsMore Productions

Ant DesignAnt Design-Enterprise UI design language
yuqueYuque-Knowledge creation and Sharing tool
EggEgg-Enterprise-class Node development framework
kitchenKitchen-Sketch Tool set
GalaceanGalacean-互动图形解决方案
xtechLiven Experience technology
© Copyright 2025 Ant Group Co., Ltd..备案号:京ICP备15032932号-38

Loading...

Overview

The sunburst chart (sunburst) serves as a powerful and intuitive data visualization tool with applications and advantages across various fields. Through its circular layout, the sunburst chart effectively displays hierarchical relationships and proportional allocation between data points, particularly suitable for datasets with clear parent-child relationships. Despite some limitations, its unique design makes it an indispensable tool in business analysis, geographical research, and other fields. Combining the advantages of pie charts and tree diagrams, it uses circular segmentation to display multi-level nested information structures. This chart type not only clearly reflects the relative sizes between different groups but also maintains excellent visual effects. Compared to tree maps, it offers advantages such as space efficiency and more intuitive overall visualization.

sunburst is implemented through g2ExtensionPlot based on rect, with internal implementation of drill-down events, polar coordinates, data transformation, style optimization, and more.

import { plotlib } from '@antv/g2-extension-plot';
import { Runtime, corelib, extend } from '@antv/g2';
const Chart = extend(Runtime, { ...corelib(), ...plotlib() });
const chart = new Chart({
container: 'container',
autoFit: true,
});
chart.options({
type: 'sunburst',
data: {
type: 'fetch',
value: 'https://gw.alipayobjects.com/os/antvdemo/assets/data/sunburst.json',
},
encode: {
value: 'sum',
},
labels: [
{
text: 'name',
transform: [
{
type: 'overflowHide',
},
],
},
],
});
chart.render();

For more examples, please check the Chart Examples - Sunburst page.

Configuration Options

PropertyDescriptionTypeDefault ValueRequired
encodeConfigure visual channels for sunburst mark, including value, etc., to specify relationships between visual element properties and dataencode-✓
coordinateConfigure coordinate system for sunburst mark, which performs a series of point transformations to change the spatial display form of the markcoordinate{type: 'polar' }
interactionConfigure interaction settings for sunburst mark, with built-in drillDown drill-down configurationinteraction{ drillDown: true }
styleConfigure graphic styles for sunburst markstyle-

encode

Configure visual channels for sunburst mark.

PropertyDescriptionTypeDefault ValueRequired
valueBind the value property channel of sunburst mark, used for numeric fields in data dataencode-✓
colorBind the color property channel of sunburst mark. If data fields are mapped to color channels, data will be grouped and split into multiple graphics with different colors, generally used for configuring stacked bar charts, etc. Built-in configuration is ancestor-node, used to distinguish different path groupsencodeancestor-node

value

The position visual channel of sunburst mark requires values from the value field. In data, values in each group are calculated through fields. Internally, tree structure data is transformed into flattened data required by rect.

{
type: 'sunburst',
data: {
value: {
name: 'root',
children: [
{
name: 'Group 1', // Automatically calculated value as 220
children: [
{ name: 'Group 1-1', count: 100 },
{ name: 'Group 1-2', count: '120' },
],
},
{
name: 'Group 2', // Automatically calculated value as 190
count: 220, // For reasonable mapping, own value won't be used
children: [
{ name: 'Group 2-1', count: 'aaa' }, // Non-numeric parameter
{ name: 'Group 2-2', count: '190' },
],
},
],
},
},
encode: { value: 'count' },
}

Tree structure data internally transformed to flattened data:

{
data: [
{ 'ancestor-node': 'Group 1', path: 'Group 1', value: 220, x: [0, 0.536...], y: [0.333.., 0.666...], depth: 1, ... },
{ 'ancestor-node': 'Group 2', path: 'Group 2', value: 190, x: [0.536..., 1], y: [0.333.., 0.666...], depth: 1, ... },
{ 'ancestor-node': 'Group 1', path: 'Group 1 / Group 1-2', value: 120, x: [0, 0.292...],y: [0.666..., 1], depth: 2, ... },
{ 'ancestor-node': 'Group 1', path: 'Group 1 / Group 1-1', value: 100, ... },
{ 'ancestor-node': 'Group 2', path: 'Group 2 / Group 2-2', value: 190, ... },
{ 'ancestor-node': 'Group 2', path: 'Group 2 / Group 2-1', value: 0, ... }, // Non-numeric defaults to 0
],
}

color

The color visual channel affects the fill color of sunburst graphic marks. When applied to interval charts, it generally maps categorical fields to group data, defaulting to the built-in ancestor-node path grouping.

import { plotlib } from '@antv/g2-extension-plot';
import { Runtime, corelib, extend } from '@antv/g2';
const Chart = extend(Runtime, { ...corelib(), ...plotlib() });
const chart = new Chart({
container: 'container',
autoFit: true,
});
chart.options({
type: 'sunburst',
data: {
type: 'fetch',
value: 'https://gw.alipayobjects.com/os/antvdemo/assets/data/sunburst.json',
},
encode: {
value: 'sum',
color: 'name',
},
});
chart.render();

Try using callback for grouping:

import { Runtime, corelib, extend } from '@antv/g2';
const Chart = extend(Runtime, { ...corelib(), ...g2ExtensionPlot.plotlib() });
const chart = new Chart({
container: 'container',
autoFit: true,
});
chart.options({
type: 'sunburst',
data: {
type: 'fetch',
value: 'https://gw.alipayobjects.com/os/antvdemo/assets/data/sunburst.json',
},
encode: {
value: 'sum',
color: (data) => {
const paths = data.path.split(' / ');
return [paths[0], paths[1]].join('/');
},
},
});
chart.render();

coordinate

sunburst has polar coordinates configured by default:

{
coordinate: {
type: 'polar',
innerRadius: 0.2,
}
}

External configuration of polar coordinate polar:

import { Runtime, corelib, extend } from '@antv/g2';
const Chart = extend(Runtime, { ...corelib(), ...g2ExtensionPlot.plotlib() });
const chart = new Chart({
container: 'container',
autoFit: true,
});
chart.options({
type: 'sunburst',
data: {
type: 'fetch',
value: 'https://gw.alipayobjects.com/os/antvdemo/assets/data/sunburst.json',
},
encode: { value: 'sum' },
coordinate: {
type: 'polar',
innerRadius: 0.3,
outerRadius: 0.9,
},
});
chart.render();

Restore to Cartesian coordinate system cartesian:

import { Runtime, corelib, extend } from '@antv/g2';
const Chart = extend(Runtime, { ...corelib(), ...g2ExtensionPlot.plotlib() });
const chart = new Chart({
container: 'container',
autoFit: true,
});
chart.options({
type: 'sunburst',
data: {
type: 'fetch',
value: 'https://gw.alipayobjects.com/os/antvdemo/assets/data/sunburst.json',
},
encode: { value: 'sum' },
coordinate: { type: 'cartesian' },
});
chart.render();

interaction

sunburst has built-in drillDown interaction events configured by default:

import { Runtime, corelib, extend } from '@antv/g2';
const Chart = extend(Runtime, { ...corelib(), ...g2ExtensionPlot.plotlib() });
const chart = new Chart({
container: 'container',
autoFit: true,
});
chart.options({
type: 'sunburst',
data: {
type: 'fetch',
value: 'https://gw.alipayobjects.com/os/antvdemo/assets/data/sunburst.json',
},
encode: { value: 'sum' },
interaction: {
drillDown: {
// Breadcrumb style
breadCrumb: {
rootText: 'Total Name',
style: {
fontSize: '18px',
fill: '#333',
},
active: {
fill: 'red',
},
},
// Whether to maintain original color after drill-down
isFixedColor: true,
},
},
});
chart.render();

style

style is used to set the appearance style of chart elements, including fill color, border style, shadow effects, etc.

PropertyDescriptionTypeDefault Value
radiusCorner radius size for all four corners of the rectanglenumber | (datum, index, data, column) => number0
radiusTopLeftTop-left corner radiusnumber | (datum, index, data, column) => number0
radiusTopRightTop-right corner radiusnumber | (datum, index, data, column) => number0
radiusBottomRightBottom-right corner radiusnumber | (datum, index, data, column) => number0
radiusBottomLeftBottom-left corner radiusnumber | (datum, index, data, column) => number0
insetInner padding in all four directions of the rectanglenumber | (datum, index, data, column) => number0
insetLeftLeft inner spacingnumber | (datum, index, data, column) => number0
insetRightRight inner spacingnumber | (datum, index, data, column) => number0
insetBottomBottom inner spacingnumber | (datum, index, data, column) => number0
insetTopTop inner spacingnumber | (datum, index, data, column) => number0
fillFill color of the graphicnumber | (datum, index, data, column) => string-
fillOpacityFill opacity of the graphicnumber | (datum, index, data, column) => number-
strokeStroke of the graphicnumber | (datum, index, data, column) => string-
strokeOpacityStroke opacitynumber | (datum, index, data, column) => number-
lineWidthWidth of the graphic strokenumber | (datum, index, data, column) => number-
lineDashDashed line configuration for stroke. First value is the length of each dash segment, second value is the spacing distance between segments. Setting lineDash to [0, 0] results in no stroke.[number,number] |(datum, index, data, column) => [number, number]-
opacityOverall opacity of the graphicnumber | (datum, index, data, column) => number-
shadowColorShadow color of the graphicnumber | (datum, index, data, column) => string-
shadowBlurGaussian blur coefficient for graphic shadownumber | (datum, index, data, column) => number-
shadowOffsetXSets the horizontal distance of shadow from the graphicnumber | (datum, index, data, column) => number-
shadowOffsetYSets the vertical distance of shadow from the graphicnumber | (datum, index, data, column) => number-
cursorMouse cursor style. Same as CSS cursor style, defaults to 'default'.number | (datum, index, data, column) => string'default'

Try it out

For more style configurations, please check the style introduction page.