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