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 = getData();
3
4
var chart = anychart.treeMap(data);
5
6
// Set hatch fill.
7
chart.hatchFill(function () {
8
if (this.index > 1)
9
return 'forward-diagonal';
10
});
11
12
chart.title('Set hatchFill parameter as an function');
13
chart.container('container');
14
chart.draw();
15
16
});
17
18
function getData() {
19
return [
20
{
21
name: 'Eurasia',
22
children: [
23
{
24
name: 'Asia', children: [
25
{
26
name: 'Eastern Asia', children: [
27
{name: 'Mongolia', value: 1564116, capital: 'Ulan-Bator'},
28
{name: 'China', value: 1564116, capital: 'Beijing'},
29
{name: 'Southern Korea', value: 1564116, capital: 'Seoul'},
30
{name: 'Northern Korea', value: 120540, capital: 'Pyongyang'},
31
{name: 'Japan', value: 1564116, capital: 'Tokio'}
32
]
33
}
34
]
35
},
36
{
37
name: 'Europe', children: [
38
{
39
name: 'Northern Europe', children: [
40
{name: 'Finland', value: 338424, capital: 'Helsinki'},
41
{name: 'Great Britain', value: 209331, capital: 'London'},
42
{name: 'Ireland', value: 84421, capital: 'Dublin'},
43
{name: 'Scandinavia', value: 928057}
44
]
45
}
46
]
47
}
48
]
49
}
50
];
51
}