HTMLcopy
1
<button onclick="label();">Apply changes (add labels)</button>
2
<button onclick="autoRedraw();">Draw changes on the chart</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;
2
anychart.onDocumentReady(function () {
3
var data = getData();
4
5
chart = anychart.tagCloud(data);
6
7
chart.title('Disable redrawing of the chart after the changes. \n Use the buttons to apply the changes and draw them');
8
chart.container('container');
9
chart.draw();
10
11
// Disable chart redrawing.
12
chart.autoRedraw(false);
13
});
14
15
function autoRedraw() {
16
17
// Enable chart redrawing.
18
chart.autoRedraw(true);
19
}
20
21
var counter = 0;
22
23
function label() {
24
chart.label(counter++, {enabled: true, offsetY: 10 * counter++, fontWeight: 600, fontColor: 'rgba(' + Math.floor(Math.random() * 130).toString(10) + ','
25
+ Math.floor(Math.random() * 140).toString(10) + ','
26
+ Math.floor(Math.random() * 150).toString(10) + ')'});
27
}
28
29
function getData() {
30
return [
31
{x: 'learning', value: 80},
32
{x: 'lists', value: 44},
33
{x: 'meaning', value: 40},
34
{x: 'useful', value: 36},
35
{x: 'different', value: 32},
36
{x: 'grammar', value: 28},
37
{x: 'teaching', value: 24},
38
{x: 'example', value: 20},
39
{x: 'includes', value: 56},
40
{x: 'thing', value: 12},
41
{x: 'vocabulary', value: 10},
42
{x: 'frequency', value: 10},
43
{x: 'phrases', value: 15},
44
{x: 'content', value: 27}
45
]
46
}