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
// access the annotations() object of the plot to work with annotations
23
var controller = plot.annotations();
24
25
// create the first Triangle annotation and configure its visual settings
26
triangle1 = controller.triangle({
27
xAnchor: "2006-03-14",
28
valueAnchor: 25.14,
29
secondXAnchor: "2007-02-25",
30
secondValueAnchor: 34.5,
31
thirdXAnchor: "2007-02-04",
32
thirdValueAnchor: 20.65,
33
hoverFill: "#398CAE 0.3",
34
hoverStroke: "2 #FF0000",
35
selectFill: "#398CAE 0.3",
36
selectHatchFill: "brick",
37
selectStroke: "5 #FF0000"
38
});
39
40
// create the second Triangle annotation
41
triangle2 = controller.triangle();
42
43
// set the position of the second annotation
44
triangle2.xAnchor("2004-09-15");
45
triangle2.valueAnchor(15);
46
triangle2.secondXAnchor("2004-12-26");
47
triangle2.secondValueAnchor(23);
48
triangle2.thirdXAnchor("2005-10-02");
49
triangle2.thirdValueAnchor(15);
50
51
// configure the visual settings of the second annotation
52
triangle2.stroke("#2196F3", 3, "10 2");
53
triangle2.fill(null);
54
55
// set the chart title
56
chart.title("Triangle: Visual Settings");
57
58
// set the container id
59
chart.container("container");
60
61
// initiate drawing the chart
62
chart.draw();
63
});