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
6
var firstSeriesData = dataSet.mapAs({
7
x: 0,
8
value: 1
9
});
10
11
// map data for the second series
12
var secondSeriesData = dataSet.mapAs({
13
x: 0,
14
value: 2
15
});
16
17
// create line chart
18
var chart = anychart.column();
19
20
// turn on chart animation
21
chart.animation(true);
22
23
chart.padding(10);
24
25
// disable Y axis
26
chart.yAxis(false);
27
28
// set X axis title
29
chart.xAxis().title('Year').stroke('black', 2);
30
31
chart.xAxis().ticks().enabled(false);
32
33
// force chart to stack values by Y scale
34
chart.yScale().stackMode('value');
35
36
// set chart title
37
chart.title('Total number of websites on the internet (2000-2015)');
38
39
// create data-area and set background settings
40
chart
41
.dataArea()
42
.background()
43
.enabled(true)
44
.fill('#456')
45
.corners(25, 25, 0, 0);
46
47
// set grid settings
48
chart
49
.xGrid()
50
.stroke('#fff .1')
51
.isMinor(true)
52
.drawFirstLine(false)
53
.drawLastLine(false);
54
55
chart
56
.yGrid()
57
.stroke('#fff .1')
58
.isMinor(true)
59
.drawFirstLine(false)
60
.drawLastLine(false);
61
62
// create first series with mapped data
63
var firstSeries = chart.column(firstSeriesData);
64
firstSeries.name('Websites');
65
66
// create second series with mapped data
67
var secondSeries = chart.column(secondSeriesData);
68
secondSeries.name('Internet Users');
69
70
// turn the legend on
71
chart
72
.legend()
73
.enabled(true)
74
.fontSize(13)
75
.fontColor('white')
76
.positionMode('inside')
77
.margin({ top: 15 });
78
79
// set container id for the chart
80
chart.container('container');
81
82
// initiate chart drawing
83
chart.draw();
84
});
85
86
function getData() {
87
return [
88
['2000', 17087182, 413425190],
89
['2001', 29254370, 500609240],
90
['2002', 38760373, 662663600],
91
['2003', 40912332, 778555680],
92
['2004', 51611646, 910060180],
93
['2005', 64780617, 1027580990],
94
['2006', 85507314, 1160335280],
95
['2007', 121892559, 1373327790],
96
['2008', 172338726, 1571601630],
97
['2009', 238027855, 1766206240],
98
['2010', 206956723, 2045865660],
99
['2011', 346004403, 2282955130],
100
['2012', 697089489, 2518453530],
101
['2013', 672985183, 2756198420],
102
['2014', 968882453, 2925249355],
103
['2015', 863105652, 3185996155]
104
];
105
}