HTMLcopy
1
<label><input onclick="sortingMode('desc')" type="radio" name="mode" checked>Descending</label>
2
<label><input onclick="sortingMode('asc')" type="radio" name="mode">Ascending</label>
3
<label><input onclick="sortingMode('none')" type="radio" name="mode">No Sorting</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: "European Union", children: [
6
{name: "Belgium", value: 11443830},
7
{name: "France", value: 64938716},
8
{name: "Germany", value: 80636124},
9
{name: "Greece", value: 10892931},
10
{name: "Italy", value: 59797978},
11
{name: "Netherlands", value: 17032845},
12
{name: "Poland", value: 38563573},
13
{name: "Romania", value: 19237513},
14
{name: "Spain", value: 46070146},
15
{name: "United Kingdom", value: 65511098}
16
]}
17
];
18
19
// create a chart and set the data
20
chart = anychart.treeMap(data, "as-tree");
21
22
// set the chart title
23
chart.title().useHtml(true);
24
chart.listen("chartDraw", function () {
25
chart.title("Treemap: Sorting Order = " + chart.sort() +
26
"<br><br><span style='font-size:12; font-style:italic'>" +
27
"Top 10 European Union Countries by Population</span>");
28
});
29
30
// set the container id
31
chart.container("container");
32
33
// initiate drawing the chart
34
chart.draw();
35
});
36
37
// set the sorting mode
38
function sortingMode(mode) {
39
chart.sort(mode);
40
}