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
dataTable.addData(get_dji_daily_short_data());
4
5
var mapping = dataTable.mapAs({value: 1});
6
7
var chart = anychart.stock();
8
9
var indicator = dataTable.createComputer(mapping);
10
indicator.addOutputField('customField', 'uid');
11
indicator.setContext({period: 2000});
12
indicator.setCalculationFunction(function(row) {
13
// Set value by column index.
14
row.setColumn(-1, row.get('value') + this.period);
15
});
16
17
var indicatorMapping = dataTable.mapAs({value: 'uid'});
18
19
var plot = chart.plot();
20
plot.column(mapping);
21
plot.line(indicatorMapping);
22
plot.getSeries(1).name('Custom indicator');
23
24
chart.title('Set value by column index');
25
chart.container('container');
26
chart.draw();
27
});