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.tagCloud(data);
5
6
// Get legend.
7
var legend = chart.legend();
8
9
legend.enabled(true).align('top');
10
legend.position('right').itemsLayout('vertical');
11
12
chart.title('Get and modify legend object');
13
chart.container('container');
14
chart.draw();
15
});
16
17
function getData() {
18
return [
19
{x: 'learning', value: 80, category: 'education'},
20
{x: 'lists', value: 44, category: 'science'},
21
{x: 'meaning', value: 40, category: 'science'},
22
{x: 'useful', value: 36, category: 'science'},
23
{x: 'different', value: 32, category: 'literacy'},
24
{x: 'grammar', value: 28, category: 'education'},
25
{x: 'teaching', value: 24, category: 'education'},
26
{x: 'example', value: 20, category: 'science'},
27
{x: 'includes', value: 56, category: 'education'},
28
{x: 'thing', value: 12, category: 'education'},
29
{x: 'vocabulary', value: 10, category: 'literacy'},
30
{x: 'frequency', value: 10, category: 'science'},
31
{x: 'phrases', value: 15, category: 'literacy'},
32
{x: 'content', value: 27, category: 'literacy'}
33
]
34
}