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