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 stage = anychart.graphics.create("container");
3
4
var charts = [];
5
6
createLabel("Render 80 Charts Async", 20, function () {
7
disposeCharts(charts);
8
9
// Set rendering mode to async.
10
createCharts(charts, true);
11
});
12
13
createLabel("Render 80 in sync", 200, function () {
14
disposeCharts(charts);
15
16
// Set rendering mode to sync.
17
createCharts(charts, false);
18
});
19
20
var customTitle = anychart.standalones.title();
21
customTitle.text("Asynchronous/synchronous Rendering");
22
customTitle.parentBounds(0, "50%", 100, 100);
23
customTitle.container(stage);
24
customTitle.draw();
25
26
function createCharts(charts, sync) {
27
for (var i = 0; i < 15; i++) {
28
for (var j = 2; j < 15; j++) {
29
pieChart = anychart.pie([Math.random(), Math.random(), Math.random()]);
30
pieChart.bounds(i * 10 + "%", j * 10 + "%", "10%", "10%");
31
pieChart.labels(false);
32
pieChart.legend(false);
33
pieChart.padding(0);
34
pieChart.margin(0);
35
pieChart.container(stage);
36
37
// Set render mode: true - async, false (default) - sync.
38
pieChart.draw(sync);
39
charts.push(pieChart);
40
}
41
}
42
}
43
44
function disposeCharts(charts) {
45
for (var i = 0; i < charts.length; i++) {
46
charts[i].dispose();
47
}
48
}
49
50
function createLabel(text, offset, action) {
51
var customLabel = anychart.standalones.label();
52
customLabel.text(text);
53
customLabel.parentBounds(offset, 30, 100, 100);
54
customLabel.listen("click", action);
55
customLabel.listen("mouseOver", function () {
56
document.body.style.cursor = "pointer";
57
});
58
customLabel.listen("mouseOut", function () {
59
document.body.style.cursor = "auto";
60
});
61
customLabel.background({fill: "#9E9E9E"});
62
customLabel.fontColor("#fff");
63
customLabel.padding(5);
64
customLabel.container(stage);
65
customLabel.draw();
66
}
67
});