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
// the data used in this sample can be obtained from the CDN
4
// https://cdn.anychart.com/csv-data/csco-daily.js
5
// create a data table using this data
6
var dataTable = anychart.data.table();
7
dataTable.addData(get_csco_daily_short_data());
8
9
// map the data
10
var mapping = dataTable.mapAs({"value": 4});
11
12
// create a stock chart
13
var chart = anychart.stock();
14
15
// create a plot on the chart
16
var plot = chart.plot(0);
17
18
// create a line series
19
var lineSeries = plot.line(mapping);
20
lineSeries.name("CSCO");
21
22
// an auxiliary variable for working with annotations
23
var controller = plot.annotations();
24
25
// create an Ellipse annotation and configure its visual settings
26
controller.ellipse({
27
xAnchor: "2006-11-20",
28
valueAnchor: 25.92,
29
secondXAnchor: "2007-02-24",
30
secondValueAnchor: 31.92,
31
hovered: {
32
fill: "#398cae 0.3",
33
stroke: "2 #ff0000"
34
},
35
selected: {
36
fill: "#398cae 0.3",
37
stroke: "4 #ff0000"
38
}
39
});
40
41
// create an Infinite Line annotation and configure its visual settings
42
controller.infiniteLine({
43
xAnchor: "2005-09-04",
44
valueAnchor: 18.58,
45
secondXAnchor: "2008-08-10",
46
secondValueAnchor: 24.91,
47
hovered: {stroke: "2 #ff0000"},
48
selected: {stroke: "4 #ff0000"}
49
});
50
51
// set the chart title
52
chart.title("Annotations: Appearance (Object Notation)");
53
54
// set the container id
55
chart.container("container");
56
57
// initiate drawing the chart
58
chart.draw();
59
});