HTMLcopy
1
<select id="typeSelect" onchange="switchType()">
2
<option value="oxygen">oxygen</option>
3
<option value="pure">pure [oxygen]</option>
4
<option value="liquid" selected>liquid [oxygen]</option>
5
</select>
6
<div id="container"></div>
CSScopy
15
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
select {
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
["pure oxygen helps people with certain illnesses"],
15
["pure oxygen can be breathed during decompression"],
16
["pure oxygen is toxic"],
17
["exposure to pure oxygen can cause lung collapse"],
18
["liquid oxygen is a pale blue cryogenic liquid"],
19
["liquid oxygen is used for industrial purposes"],
20
["liquid oxygen is a powerful oxidizing agent"],
21
["liquid oxygen is used in rocket fuel"],
22
["liquid oxygen is supplied to hospitals"]
23
];
24
25
// create a chart and set the data
26
chart = anychart.wordtree(data);
27
28
//set the root word
29
chart.word("liquid")
30
31
// configure the font
32
chart.maxFontSize(18);
33
34
// set the chart title
35
chart.title("Word Tree: Root Word");
36
37
// set the container id
38
chart.container("container");
39
40
// initiate drawing the chart
41
chart.draw();
42
});
43
44
// set the root word
45
function switchType() {
46
var select = document.getElementById("typeSelect");
47
chart.word(select.value);
48
}