HTMLcopy
1
<button onclick="drillTo();">Drill to 'has' item</button>
2
<button onclick="drillUp();">Drill up</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, item;
2
3
function drillTo() {
4
item = chart.data().search('value', 'has');
5
6
// Drill down to 'has' item.
7
chart.drillTo(item);
8
}
9
10
function drillUp() {
11
12
// Drill up.
13
chart.drillUp();
14
}
15
anychart.onDocumentReady(function () {
16
chart = anychart.wordtree(getData());
17
chart.title('Drill down to specified item and drill up');
18
chart.container('container');
19
chart.draw();
20
});
21
22
function getData() {
23
return [
24
'Earth is round',
25
'Earth is the third planet from the Sun',
26
'Earth goes around the Sun',
27
'Earth has one satellite',
28
'Earth has a radius of 6 371 km',
29
'Earth is less than the Sun',
30
'Earth is less than the Jupiter',
31
'Earth is less than the Saturn',
32
'Earth is less than the Uranus',
33
'Earth is less than the Neptune',
34
'Earth is bigger than the Venus',
35
'Earth is bigger than the Mars',
36
'Earth is bigger than the Mercury',
37
'Earth has a powerful magnetic field'
38
]
39
}