HTMLcopy
1
<button onclick="drillToItem()">Drill Down to "a"</button>
2
<button onclick="drillUpALevel()">Drill Up 1 Level</button>
3
<div id="container"></div>
CSScopy
15
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
button {
8
margin: 10px 0 0 10px;
9
}
10
#container {
11
position: absolute;
12
width: 100%;
13
top: 35px;
14
bottom: 0;
15
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// create data
4
var data = [
5
["oxygen is a chemical element"],
6
["in nature, oxygen is a gas with no color or smell"],
7
["oxygen is a very important element"],
8
["oxygen was initially discovered in 1772"],
9
["oxygen is what makes burning possible"],
10
["oxygen can be used in smelting metal from ore"],
11
["oxygen is used in hospitals for killing bacteria"],
12
["oxygen is used to purify the water"],
13
["in nature, oxygen is produced by plants"]
14
];
15
16
// create a chart and set the data
17
chart = anychart.wordtree(data);
18
19
// configure the font
20
chart.maxFontSize(18);
21
22
// set the chart title
23
chart.title("Word Tree: Interactivity");
24
25
// set the container id
26
chart.container("container");
27
28
// initiate drawing the chart
29
chart.draw();
30
});
31
32
// drill down to a data item
33
function drillToItem() {
34
/* locate an item in the data tree
35
and get it as an object */
36
var item = chart.data().search("value", "a");
37
// drill down to the item
38
chart.drillTo(item);
39
}
40
41
// drill up a level
42
function drillUpALevel() {
43
chart.drillUp();
44
}