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
// map loaded data
8
var mapping = dataTable.mapAs({'value': 4});
9
// create stock chart
10
var chart = anychart.stock();
11
// create plots on the chart
12
var plot_0 = chart.plot(0);
13
var plot_1 = chart.plot(1);
14
15
// create line series on both of them
16
var lineSeries_0 = plot_0.line(mapping);
17
lineSeries_0.name('CSCO');
18
lineSeries_0.stroke('2px #64b5f6');
19
20
var lineSeries_1 = plot_1.line(mapping);
21
lineSeries_1.name('CSCO');
22
lineSeries_1.stroke('2px #64b5f6');
23
24
// create MMA indicator with period 20 and show as line on the first plot
25
var mma10 = plot_0.mma(mapping, 10).series();
26
mma10.stroke('#bf360c');
27
28
// create MMA indicators with period 50 and show as column on the second plot
29
var mma30 = plot_1.mma(mapping, 30, "column").series();
30
mma30.fill('#ff6d00');
31
32
// set container id for the chart
33
chart.container('container');
34
// initiate chart drawing
35
chart.draw();
36
});