HTMLcopy
1
<label><input onclick="sortingMode('none')" type="radio" name="mode" checked>No Sorting</label>
2
<label><input onclick="sortingMode('asc')" type="radio" name="mode">Ascending</label>
3
<label><input onclick="sortingMode('desc')" type="radio" name="mode">Descending</label>
4
<div id="container"></div>
CSScopy
16
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
label {
8
display: inline-block;
9
margin: 10px 0 0 10px;
10
}
11
#container {
12
position: absolute;
13
width: 100%;
14
top: 35px;
15
bottom: 0;
16
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// create data
4
var data = [
5
{name: "Company A", children: [
6
{name: "Technical", children: [
7
{name: "Team Leaders", value: 7},
8
{name: "Architects", value: 3},
9
{name: "Developers", value: 35},
10
{name: "Testers", value: 15}
11
]},
12
{name: "Sales", children: [
13
{name: "Analysts", value: 12},
14
{name: "Executives", value: 8}
15
]},
16
{name: "HR", value: 3},
17
{name: "Management", value: 7}
18
]}
19
];
20
21
// create a chart and set the data
22
chart = anychart.sunburst(data, "as-tree");
23
24
// set the calculation mode
25
chart.calculationMode("parent-independent");
26
27
// set the chart title
28
chart.title().useHtml(true);
29
chart.listen("chartDraw", function () {
30
chart.title("Sunburst: Sorting Order = " +
31
chart.sort() + "<br><br>" +
32
"<span style='font-size:12; font-style:italic'>" +
33
"Number of Employees</span>");
34
});
35
36
// set the container id
37
chart.container("container");
38
39
// initiate drawing the chart
40
chart.draw();
41
});
42
43
// set the sorting mode
44
function sortingMode(mode) {
45
chart.sort(mode);
46
}