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 dataTable = anychart.data.table();
3
dataTable.addData(get_dji_daily_short_data());
4
5
var mapping = dataTable.mapAs({value: 1});
6
7
var chart = anychart.stock();
8
chart.padding(10, 10, 10, 50);
9
10
var firstPlot = chart.plot(0);
11
firstPlot.line(mapping);
12
firstPlot.annotations([{
13
type: "rectangle",
14
xAnchor: 1107129600000,
15
valueAnchor: 9000,
16
secondXAnchor: 1131408000000,
17
secondValueAnchor: 12000,
18
fill: "#4CAF50 0.5",
19
stroke: "3 #FF9800"
20
}]);
21
22
var secondPlot = chart.plot(1);
23
secondPlot.area(mapping);
24
secondPlot.annotations([{
25
type: "ellipse",
26
xAnchor: 1167782400000,
27
valueAnchor: 11000,
28
secondXAnchor: 1199232000000,
29
secondValueAnchor: 14500,
30
fill: "#4CAF50 0.5",
31
stroke: "3 #FF9800"
32
}]);
33
34
var selectAnnotation = firstPlot.annotations();
35
var annotation = chart.annotations();
36
37
// Removes annotation.
38
annotation.removeAnnotation(selectAnnotation.getAnnotationAt(0));
39
40
chart.title("Removes annotation from chart.");
41
chart.container("container");
42
chart.draw();
43
});