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
10
var mapping = dataTable.mapAs({"open": 1, "high": 2, "low": 3, "close": 4, "volume": 5});
11
12
// create stock chart
13
var chart = anychart.stock();
14
chart.left(25);
15
16
// create plots on the chart
17
var plot_0 = chart.plot(0);
18
var plot_1 = chart.plot(1);
19
var plot_2 = chart.plot(2);
20
21
// create ohlc series
22
var ohlcSeries = plot_0.ohlc(mapping);
23
ohlcSeries.name("CSCO");
24
25
// create and adjust a Volume + MA indicator
26
var volumeMa_1 = plot_1.volumeMa(mapping, 10, "sma", "area", "stepLine");
27
volumeMa_1.volumeSeries().stroke(null);
28
volumeMa_1.volumeSeries().fill("#00838f 0.4");
29
volumeMa_1.maSeries().stroke("1.5 #00838f");
30
31
// create and adjust a Volume + MA indicator
32
var volumeMa_2 = plot_2.volumeMa(mapping, 10, "ema", "area", "stepLine");
33
volumeMa_2.volumeSeries().stroke(null);
34
volumeMa_2.volumeSeries().fill("#455a64 0.4");
35
volumeMa_2.maSeries().stroke("1.5 #455a64");
36
37
// create scroller series with mapped data
38
chart.scroller().line(mapping);
39
40
// set container id for the chart
41
chart.container("container");
42
43
// initiate chart drawing
44
chart.draw();
45
});