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([6, 10, 18, 11, 9]);
5
lineChart.yScale().minimum(0);
6
lineChart.bounds(0, 20, "50%", "100%");
7
8
var controller = lineChart.annotations();
9
controller.line({
10
xAnchor: 1,
11
valueAnchor: 11,
12
secondXAnchor: 3,
13
secondValueAnchor: 12,
14
stroke: "2 #F44336"
15
});
16
17
lineChart.container(stage);
18
lineChart.draw();
19
20
21
var columnChart = anychart.column([6, 10, 18, 11, 9]);
22
columnChart.yScale().minimum(0);
23
columnChart.bounds("50%", 20, "50%", "100%");
24
25
// Returns plot annotation in JSON string.
26
var json = controller.toJson(true);
27
28
var annotation = columnChart.annotations();
29
30
// Read config from JSON string.
31
annotation.fromJson(json);
32
33
columnChart.container(stage);
34
columnChart.draw();
35
36
var customTitle = anychart.standalones.title();
37
customTitle.text("Create and read config from JSON string.");
38
customTitle.container(stage);
39
customTitle.draw();
40
});