Highcharts Demo
author(s):
Torstein Hønsi
by Hugo Carneiro
HTML
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div>
JavaScript
// Data gathered from http://populationpyramid.net/germany/2015/
// Age categories
var categories = [
'Turkey', 'Rwanda', 'Uganda',
'Poland', 'UAE', 'Qatar', 'Canada', 'South Korea',
'Australia', 'Japan', 'Chile', 'South Africa', 'Colombia',
'Russia', 'Brazil'
];
Highcharts.chart('container', {
chart: {
type: 'bar'
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: [{
categories: categories,
// reversed: false,
labels: {
step: 1
}
}],
yAxis: {
title: {
text: null
},
labels: {
formatter: function () {
return Math.abs(this.value) + '%';
}
}
},
plotOptions: {
series: {
stacking: 'normal'
}
},
tooltip: {
formatter: function () {
return '<b>' + this.series.name + ', age ' + this.point.category + '</b><br/>' +
'Population: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);
}
},
series: [{
name: 'Depreciation',
data: [-14.6, -10.0, -6.4, -6.0, 0.0, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
0.0]
}, {
name: 'Appreciation',
data: [0.0,0.0, -4.0, 0.0, 0.0, 0.0, 0.0, 0.7, 1.4, 2.7, 5.4, 6.7, 8.3, 15.9, 16.3]
}]
});