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
// create data set on our data
3
var dataSet = anychart.data.set(getData());
4
5
// map data for the first series, take x from the zero column and value from the first column of data set
6
var seriesData = dataSet.mapAs({ x: 0, value: 1 });
7
8
// create line chart
9
var chart = anychart.area3d();
10
11
// adding dollar symbols to yAxis labels
12
chart.yAxis().labels().format('${%Value}');
13
14
// turn on chart animation
15
chart.animation(true);
16
17
// set chat axes settings
18
chart.yAxis().title('The Share Price');
19
chart.xAxis().title('Year/Month/Day');
20
chart.xAxis().labels().padding([5, 5, 0, 5]);
21
22
// set chart title text settings
23
chart
24
.title()
25
.enabled(true)
26
.useHtml(true)
27
.padding([0, 0, 20, 0])
28
.text(
29
'The cost of ACME\'s shares<br/>' +
30
'<span style="color:#212121; font-size: 13px;">' +
31
'Statistics was collected from site N during September' +
32
'</span>'
33
);
34
35
// create first series with mapped data
36
var series = chart.area(seriesData);
37
series.name('ACME Share Price');
38
series.hovered().markers().enabled(true).type('circle').size(4);
39
40
// set chart tooltip settings
41
chart
42
.tooltip()
43
.position('center-top')
44
.positionMode('point')
45
.anchor('left-bottom')
46
.offsetX(5)
47
.offsetY(5);
48
49
chart.interactivity().hoverMode('by-x');
50
51
// set container id for the chart
52
chart.container('container');
53
// initiate chart drawing
54
chart.draw();
55
});
56
57
function getData() {
58
return [
59
['2015/9/1', 10],
60
['2015/9/2', 12],
61
['2015/9/3', 11],
62
['2015/9/4', 15],
63
['2015/9/5', 20],
64
['2015/9/6', 22],
65
['2015/9/7', 21],
66
['2015/9/8', 25],
67
['2015/9/9', 31],
68
['2015/9/10', 32],
69
['2015/9/11', 28],
70
['2015/9/12', 29],
71
['2015/9/13', 40],
72
['2015/9/14', 41],
73
['2015/9/15', 45],
74
['2015/9/16', 50],
75
['2015/9/17', 65],
76
['2015/9/18', 45],
77
['2015/9/19', 50],
78
['2015/9/20', 51],
79
['2015/9/21', 65],
80
['2015/9/22', 60],
81
['2015/9/23', 62],
82
['2015/9/24', 65],
83
['2015/9/25', 45],
84
['2015/9/26', 55],
85
['2015/9/27', 59],
86
['2015/9/28', 52],
87
['2015/9/29', 53],
88
['2015/9/30', 40],
89
['2015/9/31', 45]
90
];
91
}