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 an On Balance Volume indicator
26
var obv_1 = plot_1.obv(mapping, "area").series();
27
obv_1.stroke("0.5 gray");
28
obv_1.fill("#ffd54f");
29
30
// create and adjust an On Balance Volume indicator
31
var obv_2 = plot_2.obv(mapping, "stick").series();
32
obv_2.stroke("2 #ff6d00");
33
34
// create scroller series with mapped data
35
chart.scroller().line(mapping);
36
37
// set container id for the chart
38
chart.container("container");
39
40
// initiate chart drawing
41
chart.draw();
42
});