A sunburst chart draws a hierarchy as rings: the whole in the middle, each ring one level deeper. Here, what fills a laptop’s drive, folder by folder.
A sunburst shows how a total breaks down over several levels at once, with each part sized against its neighbors. It suits data that nests, like folders, budgets or product ranges, where some branches go deeper than others. The outer rings get thin quickly, so clicking into a branch does a lot of the work.
Built with amCharts 5, a JavaScript library. The JavaScript includes your theme and renderer (canvas or SVG); the JSON also follows the changes you make with the controls.
npm install @amcharts/amcharts5. See Getting started.
The same chart as a JSON config. Chart Maker reads and writes this format, the library's JSON parser turns it into a chart, and the <am5-chart> element puts it on a page with no code."type" is the class to create and "settings" what you would pass to its new() in code; "properties" fill in its parts, lists such as series and axes or templates such as columns.template; "refs" holds objects used in more than one place ("#series-0" stands for the one named series-0); a string starting with "@" takes a value from another object, such as "@series.get('fill')".
A complete page. Save it as an .html file and open it in a browser.
Paste this into an AI coding assistant to build the chart from scratch. More in amCharts & AI.
// Create root element
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
var root = am5.Root.new("chartdiv");
// Set themes
// https://www.amcharts.com/docs/v5/concepts/themes/
root.setThemes([
am5themes_Animated.new(root),
am5themes_Responsive.new(root)
]);
// Create wrapper container
var chart = root.container.children.push(am5.SerialChartContainer.new(root, {
width: am5.percent(100), // the container fills the whole chart div
height: am5.percent(100),
layout: root.verticalLayout
}));
// Create series
// https://www.amcharts.com/docs/v5/charts/hierarchy/#Adding
var series = chart.series.push(am5hierarchy.Sunburst.new(root, {
singleBranchOnly: true, // only one branch open at a time; a sunburst always works this way
// show up to 10 levels on load and on each click: more than this data has, so all of them show
downDepth: 10,
initialDepth: 10,
valueField: "value",
categoryField: "name",
childDataField: "children"
}));
// Sizes are in gigabytes; {sum} adds up everything inside a folder
series.nodes.template.set("tooltipText", "{category}: [bold]{sum} GB[/]");
// Set data: what fills a laptop's drive, folder by folder, in gigabytes
// https://www.amcharts.com/docs/v5/charts/hierarchy/#Setting_data
series.data.setAll([{
name: "Drive",
children: [{
name: "Photos",
children: [
{ name: "2023", value: 38 },
{ name: "2024", value: 52 },
{ name: "2025", value: 64 },
{ name: "2026", value: 41 }
]
}, {
name: "Videos",
children: [
{ name: "Family", value: 96 },
{
name: "Travel",
children: [
{ name: "Japan", value: 41 },
{ name: "Iceland", value: 33 }
]
}
]
}, {
name: "Apps",
children: [
{ name: "Games", value: 110 },
{ name: "Creative", value: 34 },
{ name: "Office", value: 9 }
]
}, {
name: "Documents",
children: [
{
name: "Work",
children: [
{ name: "Projects", value: 14 },
{ name: "Archive", value: 9 }
]
},
{ name: "Personal", value: 6 }
]
}, {
name: "Music",
value: 46
}, {
name: "System",
value: 32
}]
}]);
// start at the top node, so the whole drive shows
series.set("selectedDataItem", series.dataItems[0]);
// Make stuff animate on load
series.appear(1000, 100);
{
"type": "SerialChartContainer",
"settings": {
"width": {
"type": "Percent",
"value": 100
},
"height": {
"type": "Percent",
"value": 100
},
"layout": {
"type": "VerticalLayout"
}
},
"properties": {
"series": [
"#series-0"
]
},
"refs": [
{
"data-0": [
{
"name": "Drive",
"children": [
{
"name": "Photos",
"children": [
{
"name": "2023",
"value": 38
},
{
"name": "2024",
"value": 52
},
{
"name": "2025",
"value": 64
},
{
"name": "2026",
"value": 41
}
],
"__parse": true
},
{
"name": "Videos",
"children": [
{
"name": "Family",
"value": 96
},
{
"name": "Travel",
"children": [
{
"name": "Japan",
"value": 41
},
{
"name": "Iceland",
"value": 33
}
],
"__parse": true
}
],
"__parse": true
},
{
"name": "Apps",
"children": [
{
"name": "Games",
"value": 110
},
{
"name": "Creative",
"value": 34
},
{
"name": "Office",
"value": 9
}
],
"__parse": true
},
{
"name": "Documents",
"children": [
{
"name": "Work",
"children": [
{
"name": "Projects",
"value": 14
},
{
"name": "Archive",
"value": 9
}
],
"__parse": true
},
{
"name": "Personal",
"value": 6
}
],
"__parse": true
},
{
"name": "Music",
"value": 46
},
{
"name": "System",
"value": 32
}
],
"__parse": true
}
]
},
{
"series-0": {
"type": "Sunburst",
"settings": {
"singleBranchOnly": true,
"downDepth": 10,
"initialDepth": 10,
"valueField": "value",
"categoryField": "name",
"childDataField": "children",
"selectedDataItem": "@self.dataItems.0"
},
"properties": {
"data": "#data-0",
"nodes": {
"properties": {
"template": {
"settings": {
"tooltipText": "{category}: [bold]{sum} GB[/]"
}
}
}
}
}
}
}
]
}