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
3
var stage = anychart.graphics.create("container");
4
5
// main title settings
6
mainTitle = anychart.standalones.title();
7
mainTitle.parentBounds(0, 0, stage.width(), stage.height()*0.1);
8
mainTitle.text("Y axis Labels: width calculated automatically");
9
mainTitle.container(stage);
10
mainTitle.draw();
11
12
// first chart
13
firstChart = anychart.column();
14
15
// setting stroke for chart contaoner
16
firstBackground = firstChart.background();
17
firstBackground.stroke("#CCCCCC");
18
19
// setting position and bounds
20
firstChart.bounds(0, "10%", "100%", "45%");
21
22
// formatting labels value using function
23
firstYLabels = firstChart.yAxis().labels();
24
firstYLabels.format("{%value}{groupsSeparator:.}");
25
26
firstChart.column([
27
["P1", 698712],
28
["P2", 378162],
29
["P3", 739123],
30
["P4", 515632],
31
["P5", 161294]
32
]);
33
34
// draw container
35
firstChart.container(stage);
36
firstChart.draw();
37
38
// second chart
39
var secondChart = anychart.column();
40
41
// adjusting chart container position
42
secondChart.bounds(0, "55%", "100%", "45%");
43
var secondBackground = secondChart.background();
44
secondBackground.stroke("#CCCCCC");
45
46
// adjusting axis labels using function
47
var secondYLabels = secondChart.yAxis().labels();
48
49
secondChart.column([
50
["P1", 12],
51
["P2", 62],
52
["P3", 23],
53
["P4", 32],
54
["P5", 74]
55
]);
56
57
secondChart.container(stage);
58
secondChart.draw();
59
});