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
var plot_2 = chart.plot(2);
19
20
// create ohlc series
21
var ohlcSeries = plot_0.ohlc(mapping);
22
ohlcSeries.name('CSCO');
23
24
// create and adjust a Heikin-Ashi indicator
25
var ha_1 = plot_1.ha(mapping).series();
26
ha_1.risingFill("#33ccff");
27
ha_1.fallingFill("#ff33cc");
28
ha_1.risingStroke(null);
29
ha_1.fallingStroke(null);
30
31
// create and adjust a Heikin-Ashi indicator
32
var ha_2 = plot_2.ha(mapping, "ohlc").series();
33
ha_2.risingStroke("#37474f");
34
ha_2.fallingStroke("#90a4ae");
35
36
// create scroller series with mapped data
37
chart.scroller().line(mapping);
38
39
// set container id for the chart
40
chart.container("container");
41
42
// initiate chart drawing
43
chart.draw();
44
});