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
var data = anychart.data.tree([
3
{
4
name: 'Eurasia',
5
children: [
6
{
7
name: "Asia", children: [
8
{
9
name: "Eastern Asia", children: [
10
{name: "Mongolia", value: 1464116, capital: 'Ulan-Bator'},
11
{name: "China", value: 1364116, capital: 'Beijing'},
12
{name: "Southern Korea", value: 1564116, capital: 'Seoul'},
13
{name: "Northern Korea", value: 120540, capital: 'Pyongyang'},
14
{name: "Japan", value: 1564116, capital: 'Tokio'}
15
]
16
}
17
]
18
},
19
{
20
name: "Europe", children: [
21
{
22
name: "Northern Europe", children: [
23
{name: "Finland", value: 338424, capital: 'Helsinki'},
24
{name: "Great Britain", value: 209331, capital: 'London'},
25
{name: "Ireland", value: 84421, capital: 'Dublin'},
26
{name: "Scandinavia", value: 928057}
27
]
28
}
29
]
30
}
31
]
32
}
33
]);
34
35
var chart = anychart.treeMap(data, "asTree");
36
chart.maxDepth(3);
37
38
// Create color scale.
39
var customColorScale = anychart.scales.linearColor();
40
customColorScale.colors(["#2BC0E4", "#EAECC6"]);
41
42
// Set color scale.
43
chart.colorScale(customColorScale);
44
45
chart.title("Set color scale using custom colors");
46
chart.container("container");
47
chart.draw();
48
});