HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// create data
4
var data = [
5
{
6
name: "Berries", children: [
7
{name: "Blueberry", value: 25}
8
]
9
},
10
{
11
name: "Nuts", children: [
12
{
13
name: "Cashew", children: [
14
{name: "Salted", value: 2},
15
{name: "Unsalted", value: 5}
16
]
17
},
18
{name: "Almond", value: 10},
19
{name: "Walnut", value: 4},
20
{name: "Pine nut", value: 15}
21
]
22
},
23
{
24
name: "Fruits", children: [
25
{name: "Pomegranate", value: 6},
26
{
27
name: "Mango", children: [
28
{name: "Dried", value: 2},
29
{name: "Fresh", value: 3}
30
]
31
}
32
]
33
}
34
];
35
36
// create a chart and set the data
37
var chart = anychart.sunburst(data, "as-tree");
38
39
// set the calculation mode
40
chart.calculationMode("parent-independent");
41
42
// format chart labels
43
chart.labels().format('{%Name}');
44
45
// format chart labels
46
chart.tooltip().format('{%Name}:{%Value}');
47
48
// set the container id
49
chart.container("container");
50
51
// initiate drawing the chart
52
chart.draw();
53
});