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
var table, mapping, chart;
2
anychart.onDocumentReady(function () {
3
4
table = anychart.data.table();
5
table.addData([
6
['2015-12-25','512.53', '514.88', '505.69', '507.34'],
7
['2015-12-26','511.83', '514.98', '505.59', '506.23'],
8
['2015-12-27','511.22', '515.30', '505.49', '506.47'],
9
['2015-12-28','510.35', '515.72', '505.23', '505.80'],
10
['2015-12-29','510.53', '515.86', '505.38', '508.25'],
11
['2015-12-30','511.43', '515.98', '505.66', '507.45'],
12
['2015-12-31','511.50', '515.33', '505.99', '507.98'],
13
['2016-01-01','511.32', '514.29', '505.99', '506.37'],
14
['2016-01-02','511.70', '514.87', '506.18', '506.75'],
15
['2016-01-03','512.30', '514.78', '505.87', '508.67'],
16
['2016-01-04','512.50', '514.77', '505.83', '508.35'],
17
['2016-01-05','511.53', '516.18', '505.91', '509.42'],
18
['2016-01-06','511.13', '516.01', '506.00', '509.26'],
19
['2016-01-07','510.93', '516.07', '506.00', '510.99'],
20
['2016-01-08','510.88', '515.93', '505.22', '509.95'],
21
['2016-01-09','509.12', '515.97', '505.15', '510.12'],
22
['2016-01-10','508.53', '516.13', '505.66', '510.42'],
23
['2016-01-11','511.53', '516.18', '505.91', '509.42'],
24
['2016-01-12','510.35', '515.72', '505.23', '505.80'],
25
['2016-01-13','510.53', '515.86', '505.38', '508.25'],
26
['2016-01-14','511.43', '515.98', '505.66', '507.45'],
27
['2016-01-15','511.50', '515.33', '505.99', '507.98'],
28
['2016-01-16','511.32', '514.29', '505.99', '506.37'],
29
['2016-01-17','511.70', '514.87', '506.18', '506.75'],
30
['2016-01-18','512.30', '514.78', '505.87', '508.67'],
31
['2016-01-19','512.50', '514.77', '505.83', '508.35'],
32
['2016-01-20','511.53', '516.18', '505.91', '509.42'],
33
['2016-01-21','511.13', '516.01', '506.00', '509.26'],
34
['2016-01-22','510.93', '516.07', '506.00', '510.99']
35
]);
36
37
// mapping the data
38
mapping = table.mapAs();
39
mapping.addField('open', 1, 'first');
40
mapping.addField('high', 2, 'max');
41
mapping.addField('low', 3, 'min');
42
mapping.addField('close', 4, 'last');
43
mapping.addField('value', 4, 'last');
44
45
// defining the chart type
46
var chart = anychart.stock();
47
48
// set the series type
49
var ohlcSeries = chart.plot(0).ohlc(mapping);
50
ohlcSeries.name('ACME Corp.');
51
52
// add sma indicator
53
chart.plot(0).sma(mapping, 10, "line");
54
55
// setting the chart title
56
chart.title('AnyStock Basic Chart with SMA Indicator');
57
58
chart.container('container');
59
chart.draw();
60
});