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 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
10
var mapping = dataTable.mapAs({'value': 4});
11
12
//create stock chart
13
var chart = anychart.stock();
14
15
//create plot on the chart
16
var plot = chart.plot(0);
17
18
//create line series
19
var lineSeries = plot.line(mapping);
20
lineSeries.name('CSCO');
21
lineSeries.stroke('2px #64b5f6');
22
23
//create EMA indicators with period 50
24
var ema50 = plot.ema(mapping, 30).series();
25
ema50.stroke('#ffa000');
26
27
//adding extra Y axis to the right side
28
var yAxis = plot.yAxis(1);
29
yAxis.orientation('right');
30
//setting chart padding to fit both Y axes
31
chart.padding(10, 50, 10, 50);
32
33
//create scroller series with mapped data
34
chart.scroller().line(mapping);
35
36
//set chart selected date/time range
37
chart.selectRange('1990-03-26', '1995-01-03');
38
39
//set container id for the chart
40
chart.container('container');
41
42
//initiate chart drawing
43
chart.draw();
44
});