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 Fan annotation and configure its visual settings
26
var fibonacciFan1 = controller.fibonacciFan({
27
xAnchor: "2007-01-07",
28
valueAnchor: 28.92,
29
secondXAnchor: "2009-03-01",
30
secondValueAnchor: 14.18,
31
normal: {
32
labels: {fontColor: "#ff0000"},
33
grid: null
34
},
35
hovered: {
36
stroke: "#ff0000",
37
trend: "#0000ff",
38
labels: {fontColor: "#ff0000"}
39
},
40
selected: {
41
stroke: "#ff0000",
42
trend: "#0000ff",
43
grid: "#a9a9a9",
44
labels: {fontColor: "#ff0000"}
45
}
46
});
47
48
// create the second Fibonacci Fan annotation
49
var fibonacciFan2 = controller.fibonacciFan();
50
51
// set the position of the second annotation
52
fibonacciFan2.xAnchor("2006-01-29");
53
fibonacciFan2.valueAnchor(18.2);
54
fibonacciFan2.secondXAnchor("2004-01-11");
55
fibonacciFan2.secondValueAnchor(29.13);
56
57
// configure the visual settings of the second annotation
58
fibonacciFan2.normal().labels().fontColor("#00b300");
59
fibonacciFan2.normal().grid(null);
60
fibonacciFan2.normal().stroke("#006600", 1, "10 2");
61
fibonacciFan2.hovered().stroke("#00b300", 1, "10 2");
62
fibonacciFan2.selected().stroke("#00b300", 1, "10 2");
63
fibonacciFan2.selected().grid("#a9a9a9");
64
65
// set the chart title
66
chart.title("Fibonacci Fan: Appearance");
67
68
// set the container id
69
chart.container("container");
70
71
// initiate drawing the chart
72
chart.draw();
73
});