HTMLcopy
1
<button onclick="enableHeaders()">Enable headers</button>
2
<button onclick="disableHeaders();">Disable headers</button>
3
<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
var chart;
2
3
function disableHeaders() {
4
5
// Disable headers.
6
chart.headers(false);
7
}
8
9
function enableHeaders() {
10
11
// Enable headers.
12
chart.headers(true);
13
}
14
anychart.onDocumentReady(function () {
15
var data = getData();
16
17
chart = anychart.treeMap(data);
18
chart.maxDepth(2);
19
chart.title('Disable/Enable header labels');
20
chart.container('container');
21
chart.draw();
22
23
});
24
25
function getData() {
26
return [
27
{
28
name: 'Eurasia',
29
children: [
30
{
31
name: 'Asia', children: [
32
{
33
name: 'Eastern Asia', children: [
34
{name: 'Mongolia', value: 1564116, capital: 'Ulan-Bator'},
35
{name: 'China', value: 1564116, capital: 'Beijing'},
36
{name: 'Southern Korea', value: 1564116, capital: 'Seoul'},
37
{name: 'Northern Korea', value: 120540, capital: 'Pyongyang'},
38
{name: 'Japan', value: 1564116, capital: 'Tokio'}
39
]
40
}
41
]
42
},
43
{
44
name: 'Europe', children: [
45
{
46
name: 'Northern Europe', children: [
47
{name: 'Finland', value: 338424, capital: 'Helsinki'},
48
{name: 'Great Britain', value: 209331, capital: 'London'},
49
{name: 'Ireland', value: 84421, capital: 'Dublin'},
50
{name: 'Scandinavia', value: 928057}
51
]
52
}
53
]
54
}
55
]
56
}
57
];
58
}