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
// create container for two charts.
3
var stage = anychart.graphics.create('container');
4
5
// create data table
6
var table = anychart.data.table();
7
// add data
8
table.addData([
9
['2015-12-01', 511.53, 514.98, 505.79, 506.40],
10
['2015-12-12', 512.53, 514.88, 505.69, 510.34],
11
['2015-12-26', 511.83, 514.98, 505.59, 507.23],
12
['2015-12-27', 511.22, 515.30, 505.49, 506.47],
13
['2015-12-28', 511.53, 514.98, 505.79, 506.40],
14
['2015-12-29', 512.53, 513.88, 505.69, 510.34],
15
['2015-12-30', 511.83, 512.98, 502.59, 503.23],
16
['2015-12-31', 511.22, 515.30, 505.49, 506.47]
17
]);
18
19
// map loaded data
20
var mapping = table.mapAs({'open': 1, 'high': 2, 'low': 3, 'close': 4});
21
22
// create ordinal (default) stock chart
23
var chart1 = anychart.stock();
24
// set x scale type
25
chart1.xScale('ordinal');
26
// configure and display chart
27
chart1.title('Ordinal Time Scale');
28
chart1.plot(0).ohlc(mapping).name('ACME Corp. Stock Prices');
29
chart1.bounds(0, 0, '100%', '50%');
30
chart1.container(stage).draw();
31
32
// create scatter stock chart
33
var chart2 = anychart.stock();
34
// set x scale type
35
chart2.xScale('scatter');
36
// configure and display chart
37
chart2.title('Scatter Time Scale');
38
chart2.plot(0).ohlc(mapping).name('ACME Corp. Stock Prices');
39
chart2.bounds(0, '50%', '100%', '50%');
40
chart2.container(stage).draw();
41
});