HTMLcopy
1
<button onclick="enableBackground()">Enable background</button>
2
<button onclick="disableBackground();">Disable background</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 disableBackground() {
4
5
// Disable background.
6
chart.background(false);
7
}
8
9
function enableBackground() {
10
11
// Enable background.
12
chart.background(true);
13
}
14
anychart.onDocumentReady(function () {
15
var data = getData();
16
17
chart = anychart.treeMap(data);
18
chart.background('#FFF59D 0.4');
19
chart.padding(100);
20
chart.title('Enable/Disable chart background');
21
chart.container('container');
22
chart.draw();
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
}