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 Fibonacci Retracement annotation and configure its visual settings
26
fibonacciRetracement1 = controller.fibonacciRetracement({
27
xAnchor: "2006-07-30",
28
valueAnchor: 17.24,
29
secondXAnchor: "2007-01-07",
30
secondValueAnchor: 28.92,
31
hoverTrend: "#0000FF",
32
hoverStroke: "#FF0000",
33
selectTrend: "2 #0000FF",
34
selectStroke: "2 #FF0000"
35
});
36
37
// create the second Fibonacci Retracement annotation
38
fibonacciRetracement2 = controller.fibonacciRetracement();
39
40
// set the position of the second annotation
41
fibonacciRetracement2.xAnchor("2004-01-11");
42
fibonacciRetracement2.valueAnchor(29.13);
43
fibonacciRetracement2.secondXAnchor("2004-08-08");
44
fibonacciRetracement2.secondValueAnchor(17.86);
45
46
// configure the visual settings of the second annotation
47
fibonacciRetracement2.stroke("#2196F3", 2, "10 2");
48
49
// set the chart title
50
chart.title("Fibonacci Retracement: Visual Settings");
51
52
// set the container id
53
chart.container("container");
54
55
// initiate drawing the chart
56
chart.draw();
57
});