index.htm 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title>Highcharts Example</title>
  7. <style type="text/css">
  8. </style>
  9. </head>
  10. <body>
  11. <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
  12. <script src="../../code/highcharts.js"></script>
  13. <script src="../../code/modules/exporting.js"></script>
  14. <div id="container" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div>
  15. <script type="text/javascript">
  16. // Data gathered from http://populationpyramid.net/germany/2015/
  17. // Age categories
  18. var categories = [
  19. '0-4', '5-9', '10-14', '15-19',
  20. '20-24', '25-29', '30-34', '35-39', '40-44',
  21. '45-49', '50-54', '55-59', '60-64', '65-69',
  22. '70-74', '75-79', '80-84', '85-89', '90-94',
  23. '95-99', '100 + '
  24. ];
  25. Highcharts.chart('container', {
  26. chart: {
  27. type: 'bar'
  28. },
  29. title: {
  30. text: 'Population pyramid for Germany, 2018'
  31. },
  32. subtitle: {
  33. text: 'Source: <a href="http://populationpyramid.net/germany/2018/">Population Pyramids of the World from 1950 to 2100</a>'
  34. },
  35. xAxis: [{
  36. categories: categories,
  37. reversed: false,
  38. labels: {
  39. step: 1
  40. }
  41. }, { // mirror axis on right side
  42. opposite: true,
  43. reversed: false,
  44. categories: categories,
  45. linkedTo: 0,
  46. labels: {
  47. step: 1
  48. }
  49. }],
  50. yAxis: {
  51. title: {
  52. text: null
  53. },
  54. labels: {
  55. formatter: function () {
  56. return Math.abs(this.value) + '%';
  57. }
  58. }
  59. },
  60. plotOptions: {
  61. series: {
  62. stacking: 'normal'
  63. }
  64. },
  65. tooltip: {
  66. formatter: function () {
  67. return '<b>' + this.series.name + ', age ' + this.point.category + '</b><br/>' +
  68. 'Population: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);
  69. }
  70. },
  71. series: [{
  72. name: 'Male',
  73. data: [
  74. -2.2, -2.1, -2.2, -2.4,
  75. -2.7, -3.0, -3.3, -3.2,
  76. -2.9, -3.5, -4.4, -4.1,
  77. -3.4, -2.7, -2.3, -2.2,
  78. -1.6, -0.6, -0.3, -0.0,
  79. -0.0
  80. ]
  81. }, {
  82. name: 'Female',
  83. data: [
  84. 2.1, 2.0, 2.1, 2.3, 2.6,
  85. 2.9, 3.2, 3.1, 2.9, 3.4,
  86. 4.3, 4.0, 3.5, 2.9, 2.5,
  87. 2.7, 2.2, 1.1, 0.6, 0.2,
  88. 0.0
  89. ]
  90. }]
  91. });
  92. </script>
  93. </body>
  94. </html>