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
// map loaded data
9
var mapping = dataTable.mapAs({"open": 1, "high": 2, "low": 3, "close": 4});
10
11
// create stock chart
12
var chart = anychart.stock();
13
14
// create plots on the chart
15
var plot_0 = chart.plot(0);
16
var plot_1 = chart.plot(1);
17
var plot_2 = chart.plot(2);
18
19
// configure the y-scale of the second and third plot
20
plot_1.yScale().minimum(-100);
21
plot_1.yScale().maximum(0);
22
plot_2.yScale().minimum(-100);
23
plot_2.yScale().maximum(0);
24
25
// create ohlc series
26
var ohlcSeries = plot_0.ohlc(mapping);
27
ohlcSeries.name("CSCO");
28
29
// create and adjust the Williams %R indicator with settings adjusted
30
var williamsR_1 = plot_1.williamsR(mapping, 5, "area").series();
31
williamsR_1.stroke("0.5 gray");
32
williamsR_1.fill("#ffd54f");
33
34
// create and adjust the Williams %R indicator with settings adjusted
35
var williamsR_2 = plot_2.williamsR(mapping, 60, "column").series();
36
williamsR_2.stroke("0.5 lightGray");
37
williamsR_2.fill("#ff6d00");
38
39
// set container id for the chart
40
chart.container('container');
41
// initiate chart drawing
42
chart.draw();
43
});