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 chart1 = anychart.column();
5
chart1.bounds(0, 0, '100%', '50%');
6
7
var series1 = chart1.column([
8
{x: 'January', value: 2},
9
{x: 'February', value: 5},
10
{x: 'March', value: 3},
11
{x: 'April', value: 9},
12
{x: 'May', value: 4}
13
]);
14
15
var labels = series1.labels();
16
labels.enabled(true);
17
labels.offsetX(50);
18
19
chart1.container(stage);
20
chart1.draw();
21
22
var chart2 = anychart.line();
23
chart2.bounds(0, '50%', '100%', '50%');
24
25
var series2 = chart2.line([
26
{x: 'January', value: 2},
27
{x: 'February', value: 5},
28
{x: 'March', value: 3},
29
{x: 'April', value: 9},
30
{x: 'May', value: 4}
31
]);
32
33
var lineLabels = series2.labels();
34
lineLabels.enabled(true);
35
36
// Get offset by X.
37
var offsetX = labels.offsetX();
38
39
lineLabels.offsetX(offsetX);
40
chart2.container(stage);
41
chart2.draw();
42
43
var title = anychart.standalones.title();
44
title.text('Get and use offset by X');
45
title.container(stage);
46
title.draw();
47
});