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
var dataTable = anychart.data.table();
3
4
// The data used in this sample can be obtained from the CDN
5
// https://cdn.anychart.com/csv-data/dji-daily-short.js
6
dataTable.addData(get_dji_daily_short_data());
7
8
var mapping = dataTable.mapAs();
9
mapping.addField('value', 4, 'last');
10
11
var chart = anychart.stock();
12
13
// Create computer.
14
var computer = dataTable.createComputer(mapping);
15
16
var context = anychart.math.bbandsWidth.initContext(30, 5);
17
18
// Set init context.
19
computer.setContext(context);
20
21
// Set start calculation function.
22
computer.setStartFunction(anychart.math.bbandsWidth.startFunction);
23
24
// Calculation function.
25
computer.setCalculationFunction(anychart.math.bbandsWidth.calculationFunction);
26
27
var indicatorMapping = dataTable.mapAs({value: computer.addOutputField('result')});
28
29
var plot = chart.plot();
30
plot.line(indicatorMapping).name('BBands Width(30,5)');
31
32
chart.container('container');
33
chart.draw();
34
});