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
26
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
// create data table on loaded data
5
var dataTable = anychart.data.table();
6
dataTable.addData(get_csco_daily_data());
7
// map loaded data
8
var mapping = dataTable.mapAs({'value': 4});
9
// create stock chart
10
var chart = anychart.stock();
11
// create plot on the chart
12
var plot = chart.plot(0);
13
// create line series
14
var lineSeries = plot.line(mapping);
15
lineSeries.name('CSCO');
16
lineSeries.stroke('2px #64b5f6');
17
// create SMA indicators with period 20
18
var ema20 = plot.ema(mapping, 20).series();
19
ema20.stroke('#bf360c');
20
// create scroller series with mapped data
21
chart.scroller().line(mapping);
22
// set container id for the chart
23
chart.container('container');
24
// initiate chart drawing
25
chart.draw();
26
});