HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
//create column chart
3
var chart = anychart.column();
4
//turn on chart animation
5
chart.animation(true);
6
7
//create area series with passed data
8
var series = chart.stick(getData());
9
//set series tooltip settings
10
series.tooltip().format(function () {
11
return 'Population in 2016: ' + this.value.toLocaleString() + ' mln'
12
});
13
14
//set scale minimum
15
chart.yScale().minimum(0).ticks().interval(5);
16
//tooltips position and interactivity settings
17
chart.tooltip().positionMode('point');
18
chart.interactivity().hoverMode('by-x');
19
//axes titles
20
chart.yAxis().title('Population (millions)');
21
chart.xAxis().labels().rotation(-90);
22
//set container id for the chart
23
chart.container('container');
24
//initiate chart drawing
25
chart.draw();
26
});
27
28
function getData() {
29
return [
30
['Shanghai', 24.2],
31
['Karachi', 23.5],
32
['Beijing', 21.5],
33
['Delhi', 16.7],
34
['Lagos', 16.0],
35
['Tianjin', 15.2],
36
['Istanbul', 14.1],
37
['Tokyo', 13.5],
38
['Guangzhou', 13],
39
['Mumbai', 12.4],
40
['Moscow', 12.1],
41
['S?o Paulo', 11.8],
42
['Shenzhen', 10.4],
43
['Jakarta', 10.1],
44
['Lahore', 10],
45
['Seoul', 9.9],
46
['Wuhan', 9.7],
47
['Kinshasa', 9.7],
48
['Cairo', 9.2],
49
['Mexico City', 8.8]
50
]
51
}