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 lineChart = anychart.line([
5
{x: 0, value: 6},
6
{x: 1, value: 10},
7
{x: 2, value: 18},
8
{x: 3, value: 11},
9
{x: 4, value: 9}
10
]);
11
lineChart.yScale().minimum(0);
12
lineChart.bounds(0, 20, '50%', '100%');
13
14
var controller = lineChart.annotations();
15
controller.line({
16
xAnchor: 1,
17
valueAnchor: 11,
18
secondXAnchor: 3,
19
secondValueAnchor: 12,
20
stroke: '2 #F44336'
21
});
22
23
lineChart.container(stage);
24
lineChart.draw();
25
26
27
var columnChart = anychart.column([
28
{x: 0, value: 6},
29
{x: 1, value: 10},
30
{x: 2, value: 18},
31
{x: 3, value: 11},
32
{x: 4, value: 9}
33
]);
34
columnChart.yScale().minimum(0);
35
columnChart.bounds('50%', 20, '50%', '100%');
36
37
// Returns plot annotation in XML string.
38
var xml = controller.toXml();
39
40
var annotation = columnChart.annotations();
41
42
// Read config from XML string.
43
annotation.fromXml(xml);
44
45
columnChart.container(stage);
46
columnChart.draw();
47
48
var customTitle = anychart.standalones.title();
49
customTitle.text('Create and read config from XML string');
50
customTitle.container(stage);
51
customTitle.draw();
52
});