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
// The data that used in this sample can be obtained from the CDN
3
// https://cdn.anychart.com/csv-data/csco-daily.js
4
5
// create data table on loaded data
6
var dataTable = anychart.data.table();
7
dataTable.addData(get_csco_daily_data());
8
9
// map loaded data for the ohlc series
10
var mapping = dataTable.mapAs();
11
mapping.addField('open', 1, 'first');
12
mapping.addField('high', 2, 'max');
13
mapping.addField('low', 3, 'min');
14
mapping.addField('close', 4, 'last');
15
mapping.addField('value', 4, 'close');
16
17
// create stock chart
18
var chart = anychart.stock();
19
20
// create first plot on the chart
21
var plot_0 = chart.plot(0);
22
23
// create ohlc series
24
var ohlcSeries = plot_0.ohlc(mapping);
25
ohlcSeries.name('CSCO');
26
27
// create second plot on the chart
28
var plot_1 = chart.plot(1);
29
plot_1.height('25%');
30
31
// create Aroon indicator with period 25 and shown as steplines on the second plot
32
aroon25 = plot_1.aroon(mapping, 25, "step-line", "step-line");
33
aroon25.upSeries().stroke('#bf360c');
34
aroon25.downSeries().stroke('#ff6d00');
35
aroon25.rangeSeries().fill('#ffd54f 0.2');
36
37
// create third plot on the chart
38
var plot_2 = chart.plot(2);
39
plot_2.height('25%');
40
41
// create Aroon indicator with period 30 and shown as splines on the third plot
42
aroon30 = plot_2.aroon(mapping);
43
aroon30.period(30);
44
aroon30.upSeries().seriesType("spline");
45
aroon30.upSeries().stroke('#bf360c', 2, '5 5 10');
46
aroon30.downSeries().seriesType("spline");
47
aroon30.downSeries().stroke('#ff6d00', 2, '5 5 10');
48
aroon30.rangeSeries().fill("none");
49
50
// create scroller series with mapped data
51
chart.scroller().line(mapping);
52
53
// set container id for the chart
54
chart.container('container');
55
56
// initiate chart drawing
57
chart.draw();
58
});