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
3
// create data
4
var data = [
5
{name: "Slavic Languages",
6
normal: {header: {
7
format: "{%name} ({%value} Total)",
8
fontColor: "#990000",
9
fontSize: "14",
10
fontWeight: "bold"
11
}
12
},
13
hovered: {header: {fontColor: "#000099"}},
14
children: [
15
{name: "East Slavic", header: null, children: [
16
{name: "Russian", value: 150000000},
17
{name: "Ukrainian", value: 45000000},
18
{name: "Belarusian", value: 3200000}
19
]},
20
{name: "West Slavic", header: null, children: [
21
{name: "Polish", value: 55000000},
22
{name: "Czech", value: 10600000},
23
{name: "Slovak", value: 5200000}
24
]},
25
{name: "South Slavic", header: null, children: [
26
{name: "Serbo-Croatian", value: 21000000},
27
{name: "Bulgarian", value: 9000000},
28
{name: "Slovene", value: 2500000},
29
{name: "Macedonian", value: 1400000}
30
]}
31
]}
32
];
33
34
// create a chart and set the data
35
var chart = anychart.treeMap(data, "as-tree");
36
37
// set the maximum depth of levels shown
38
chart.maxDepth(3);
39
40
// set the chart title
41
chart.title().useHtml(true);
42
chart.title("Treemap: Individual Headers<br><br>" +
43
"<span style='font-size:12; font-style:italic'>" +
44
"Slavic Languages by Number of Speakers</span>");
45
46
// set the container id
47
chart.container("container");
48
49
// initiate drawing the chart
50
chart.draw();
51
});