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