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 that used in this sample can be obtained from the CDN
3
// https://cdn.anychart.com/csv-data/csco-daily.js
4
5
// create data table on loaded data
6
var dataTable = anychart.data.table();
7
dataTable.addData(get_csco_daily_data());
8
9
// map loaded data
10
var mapping = dataTable.mapAs({"open": 1, "high": 2, "low": 3, "close": 4});
11
12
// create stock chart
13
var chart = anychart.stock();
14
15
// create plots on the chart
16
var plot_0 = chart.plot(0);
17
var plot_1 = chart.plot(1);
18
19
// create ohlc series on both of them
20
var ohlcSeries_0 = plot_0.ohlc(mapping);
21
ohlcSeries_0.name("CSCO");
22
23
var ohlcSeries_1 = plot_1.ohlc(mapping);
24
ohlcSeries_1.name("CSCO");
25
26
// create and adjust a Keltner Channels indicator
27
var keltnerChannels_0 = plot_0.keltnerChannels(mapping, 10, 15, "sma", 4);
28
keltnerChannels_0.maSeries().stroke("2 #ef6c00");
29
keltnerChannels_0.rangeSeries().fill("#ffd54f 0.2");
30
keltnerChannels_0.rangeSeries().highStroke("2 #00bfa5");
31
keltnerChannels_0.rangeSeries().lowStroke("2 #dd2c00");
32
33
// create and adjust a Keltner Channels indicator
34
var keltnerChannels_1 = plot_1.keltnerChannels(mapping, 10, 15, "sma", 4, "step-line", "step-range-area");
35
keltnerChannels_1.maSeries().stroke("2 #64b5f6");
36
keltnerChannels_1.rangeSeries().fill("none");
37
keltnerChannels_1.rangeSeries().lowStroke("2 #00bfa5");
38
keltnerChannels_1.rangeSeries().highStroke("2 #00bfa5");
39
40
// create scroller series with mapped data
41
chart.scroller().line(mapping);
42
43
// set container id for the chart
44
chart.container("container");
45
46
// initiate chart drawing
47
chart.draw();
48
});