HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
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.csv
4
anychart.data.loadCsvFile(
5
'https://cdn.anychart.com/csv-data/csco-daily.csv',
6
function (data) {
7
// create data table on loaded data
8
var dataTable = anychart.data.table();
9
dataTable.addData(data);
10
11
// map loaded data
12
var mapping = dataTable.mapAs({
13
open: 1,
14
high: 2,
15
low: 3,
16
close: 4,
17
volume: 1,
18
value: 4
19
});
20
21
// create stock chart
22
var chart = anychart.stock();
23
// setting chart padding to fit both Y axes
24
chart.padding(10, 50, 20, 50);
25
26
// create plot on the chart
27
var plot = chart.plot(0);
28
// adding extra Y axis to the right side
29
plot.yAxis(1).orientation('right');
30
// create line series
31
plot.ohlc().data(mapping).name('CSCO').stroke('2px #64b5f6');
32
33
var indicatorPlot = chart.plot(1);
34
// set plot height
35
indicatorPlot.height('30%');
36
// adding extra Y axis to the right side
37
indicatorPlot.yAxis(1).orientation('right');
38
// create Williams %R indicator with period 12 and Spline type series
39
indicatorPlot.williamsR(mapping, 12, 'spline');
40
// create scroller series with mapped data
41
chart.scroller().line(mapping);
42
43
// set chart selected date/time range
44
chart.selectRange('2004-01-04', '2008-06-01');
45
// set container id for the chart
46
chart.container('container');
47
// initiate chart drawing
48
chart.draw();
49
50
// create range picker
51
var rangePicker = anychart.ui.rangePicker();
52
// init range picker
53
rangePicker.render(chart);
54
55
// create range selector
56
var rangeSelector = anychart.ui.rangeSelector();
57
// init range selector
58
rangeSelector.render(chart);
59
}
60
);
61
});