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
var mapping = dataTable.mapAs({
9
'open': 1,
10
'high': 2,
11
'low': 3,
12
'close': 4,
13
'value': {column: 4, type: 'close'}
14
});
15
16
// create stock chart
17
var chart = anychart.stock();
18
19
// create ohlc series
20
chart.plot(0).ohlc(mapping).name('CSCO');
21
22
// create Bollinger Bands %B indicator with period 10 and show as a line on the second plot
23
var BBandsB10 = chart.plot(1).bbandsB(mapping, 10, 0.2, "line").series();
24
BBandsB10.stroke('#bf360c');
25
26
// create Bollinger Bands %B indicator with period 50 and show as a column on the third plot
27
var BBandsB50 = chart.plot(2).bbandsB(mapping, 50, 0.6, "column").series();
28
BBandsB50.fill('#ff6d00');
29
30
// create scroller series with mapped data
31
chart.scroller().line(mapping);
32
33
// set container id for the chart
34
chart.container('container');
35
36
// initiate chart drawing
37
chart.draw();
38
});