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 plot on the chart
20
var plotSeries = chart.plot(0);
21
var plotIndicator = chart.plot(1);
22
23
// create line series
24
plotSeries.ohlc(mapping).name('TSLA');
25
26
// create BBands indicators
27
plotIndicator.bbandsB(mapping);
28
29
// create scroller series with mapped data
30
chart.scroller().line(mapping);
31
32
// set container id for the chart
33
chart.container('container');
34
35
// initiate chart drawing
36
chart.draw();
37
});