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
// create a stage for two charts
4
var stage = anychart.graphics.create("container",600,800);
5
6
// setting data
7
var data = anychart.data.set([
8
["January", 200, 180],
9
["February", 289, 290],
10
["March", 197, 370],
11
["April", 210, 400],
12
["May", 220, 120],
13
["June", 215, 214],
14
["July", 209, 153],
15
["August", 357, 257],
16
["September", 333, 183],
17
["October", 218, 236],
18
["November", 289, 147],
19
["December", 266, 368]
20
]);
21
22
// data remapping
23
var Sales2003 = data.mapAs({x: [0], value: [1]});
24
var Sales2004 = data.mapAs({x: [0], value: [2]});
25
26
// create a chart
27
var chart_1 = anychart.column();
28
29
// set chart title
30
chart_1.title("Adaptive Stagger Labels");
31
32
// series data
33
chart_1.column(Sales2003);
34
chart_1.column(Sales2004);
35
36
// enables stagger mode
37
chart_1.xAxis().staggerMode(true);
38
// set the number of maximum lines for labels to stagger
39
// if chart is able to fit labels without staggering or staggering
40
// in 2 or 3 lines - it will do so. It will not go over 4 lines:
41
chart_1.xAxis().staggerMaxLines(4);
42
43
// create a chart
44
var chart_2 = anychart.column();
45
46
// set chart title
47
chart_2.title("Fixed Stagger Labels");
48
49
// series data
50
chart_2.column(Sales2003);
51
chart_2.column(Sales2004);
52
53
// enables stagger mode
54
chart_2.xAxis().staggerMode(true);
55
// set the number of lines for labels to stagger
56
chart_2.xAxis().staggerLines(3);
57
58
// place charts on the stage
59
chart_1.bounds(0, 0, "100%", "50%");
60
chart_1.container(stage).draw();
61
62
chart_2.bounds(0, "50%", "100%", "50%");
63
chart_2.container(stage).draw();
64
});