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
chart.padding(10, 10, 10, 50);
9
10
var indicator = dataTable.createComputer(mapping);
11
indicator.addOutputField("customField", "uid");
12
indicator.setContext({period: 2000, queue: 257});
13
14
// Sets initial function.
15
indicator.setStartFunction(function (context) {
16
context.period *= 2;
17
});
18
indicator.setCalculationFunction(function (row) {
19
row.set("customField", row.get("value") + this.period);
20
});
21
22
var indicatorMapping = dataTable.mapAs({value: "uid"});
23
24
var plot = chart.plot();
25
plot.column(mapping);
26
plot.line(indicatorMapping);
27
plot.getSeries(1).name("Custom indicator");
28
29
chart.container("container");
30
chart.draw();
31
});