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 vertical area chart
9
var chart = anychart.verticalArea();
10
11
// set chart padding
12
chart.padding().right(20);
13
14
// turn on chart animation
15
chart.animation(true);
16
17
// adding dollar symbols to yAxis labels
18
chart.yAxis().labels().format('${%Value}');
19
20
// axes settings
21
chart.yAxis().title('Price');
22
chart.xAxis().title('Date');
23
24
// set chart title text settings
25
chart
26
.title()
27
.enabled(true)
28
.useHtml(true)
29
.padding([0, 0, 20, 0])
30
.text(
31
'ACME Share Price<br/>' +
32
'<span style="color:#212121; font-size: 13px;">September 2015</span>'
33
);
34
35
// create a series with mapped data
36
var series = chart.area(seriesData);
37
series
38
.name('ACME Share Price')
39
// turn on series markers
40
.markers(true);
41
series.hovered().markers().enabled(true).type('circle').size(4);
42
43
// set chart tooltip and interactivity settings
44
chart
45
.tooltip()
46
.position('right')
47
.anchor('left-center')
48
.positionMode('point');
49
50
chart.interactivity().hoverMode('by-x');
51
52
// set container id for the chart
53
chart.container('container');
54
// initiate chart drawing
55
chart.draw();
56
});
57
58
function getData() {
59
return [
60
['2015/9/01', 10],
61
['2015/9/02', 12],
62
['2015/9/03', 11],
63
['2015/9/04', 15],
64
['2015/9/05', 20],
65
['2015/9/06', 22],
66
['2015/9/07', 21],
67
['2015/9/08', 25],
68
['2015/9/09', 31],
69
['2015/9/10', 32],
70
['2015/9/11', 28],
71
['2015/9/12', 29],
72
['2015/9/13', 40],
73
['2015/9/14', 41],
74
['2015/9/15', 45],
75
['2015/9/16', 50],
76
['2015/9/17', 65],
77
['2015/9/18', 45],
78
['2015/9/19', 50],
79
['2015/9/20', 51],
80
['2015/9/21', 65],
81
['2015/9/22', 60],
82
['2015/9/23', 62],
83
['2015/9/24', 65],
84
['2015/9/25', 45],
85
['2015/9/26', 55],
86
['2015/9/27', 59],
87
['2015/9/28', 52],
88
['2015/9/29', 53],
89
['2015/9/30', 40]
90
];
91
}