HTMLcopy
1
<div id="container"></div>
CSScopy
15
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
button {
8
margin: 10px 0 0 10px;
9
}
10
#container {
11
position: absolute;
12
width: 100%;
13
top: 35px;
14
bottom: 0;
15
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// create data table on loaded data
4
var dataTable = anychart.data.table();
5
dataTable.addData([
6
["2004-06-02", 88.64, 88.64, 87.89, 87.98, 3912600],
7
["2004-06-03", 87.85, 88.1, 87.35, 87.35, 3011500],
8
["2004-06-04", 87.95, 88.49, 87.5, 87.56, 3803400],
9
["2004-06-07", 88.75, 88.99, 88.01, 88.64, 4264500],
10
["2004-06-08", 88.64, 90.5, 88.4, 90.04, 5400300],
11
["2004-06-09", 89.9, 90.55, 89.81, 90.09, 5233400],
12
["2004-06-10", 90.23, 90.75, 89.89, 90.46, 3468700],
13
["2004-06-14", 90.05, 90.58, 89.62, 90.07, 4121400],
14
["2004-06-15", 90.49, 91.21, 90.23, 90.54, 4508300],
15
["2004-06-16", 90.25, 90.93, 90.09, 90.38, 3145700],
16
["2004-06-17", 90.5, 90.56, 90.07, 90.44, 4180200],
17
["2004-06-18", 90.2, 90.8, 89.9, 90.06, 6470800],
18
["2004-06-21", 90.4, 90.43, 89.31, 89.49, 3843400],
19
["2004-06-22", 89.28, 90.24, 89.13, 90.02, 4149300],
20
["2004-06-23", 90.1, 90.84, 89.84, 90.79, 4354700],
21
["2004-06-24", 90.28, 90.92, 89.84, 89.99, 4069400],
22
["2004-06-25", 89.95, 90.23, 88.94, 89.55, 5604700],
23
["2004-06-28", 89.71, 89.9, 88.36, 88.71, 4423200],
24
["2004-06-29", 88.35, 88.49, 87.9, 88.29, 4394800],
25
["2004-06-30", 88.3, 88.5, 87.7, 88.15, 4724000]
26
]);
27
28
// map loaded data
29
mapping = dataTable.mapAs({'value': 2});
30
ohlcMapping = dataTable.mapAs({'open': 1, 'high': 2, 'low': 3, 'close':4});
31
columnMapping = dataTable.mapAs({'value': 3});
32
33
// create stock chart
34
chart = anychart.stock();
35
36
// create first plot on the chart
37
var plot_1 = chart.plot(0);
38
plot_1.line(mapping).name('Trend');
39
40
// create second plot on the chart
41
var plot_2 = chart.plot(1);
42
plot_2.ohlc(ohlcMapping).name('Price');
43
44
// create the third plot on the chart
45
var plot_3 = chart.plot(2);
46
plot_3.column(mapping).name('High');
47
48
// change splitter
49
chart.splitters().normal().stroke({
50
color: 'red',
51
dash: '3 4',
52
thickness: 1,
53
opacity: 0.9
54
});
55
chart.splitters().hovered().stroke({
56
color: 'blue',
57
dash: '3 4',
58
thickness: 2,
59
opacity: 0.9
60
});
61
chart.splitters().preview().fill({
62
//color: 'lightgreen',
63
opacity: 0.5
64
});
65
66
// set container id for the chart
67
chart.container('container');
68
69
// initiate chart drawing
70
chart.draw();
71
});