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();
6
mapping.addField('open', 1, 'first');
7
mapping.addField('high', 2, 'max');
8
mapping.addField('low', 3, 'min');
9
mapping.addField('close', 4, 'last');
10
mapping.addField('value', 3, 'last');
11
12
var chart = anychart.stock();
13
chart.padding(10, 10, 10, 50);
14
15
var plot = chart.plot();
16
plot.ohlc(mapping);
17
18
var indicatorPlot = chart.plot(1);
19
indicatorPlot.height("30%");
20
21
var stochasticIndicator = indicatorPlot.stochastic(mapping);
22
23
// Set %K Period.
24
stochasticIndicator.kPeriod(20);
25
26
chart.title("Set %K Period");
27
chart.container("container");
28
chart.draw();
29
});