index.htm 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Highcharts Example</title>
  6. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  7. <script type="text/javascript">
  8. $(function () {
  9. var chart,
  10. categories = ['0-4', '5-9', '10-14', '15-19',
  11. '20-24', '25-29', '30-34', '35-39', '40-44',
  12. '45-49', '50-54', '55-59', '60-64', '65-69',
  13. '70-74', '75-79', '80-84', '85-89', '90-94',
  14. '95-99', '100 +'];
  15. $(document).ready(function() {
  16. $('#container').highcharts({
  17. chart: {
  18. type: 'bar'
  19. },
  20. title: {
  21. text: 'Population pyramid for Germany, midyear 2010'
  22. },
  23. subtitle: {
  24. text: 'Source: www.census.gov'
  25. },
  26. xAxis: [{
  27. categories: categories,
  28. reversed: false
  29. }, { // mirror axis on right side
  30. opposite: true,
  31. reversed: false,
  32. categories: categories,
  33. linkedTo: 0
  34. }],
  35. yAxis: {
  36. title: {
  37. text: null
  38. },
  39. labels: {
  40. formatter: function(){
  41. return (Math.abs(this.value) / 1000000) + 'M';
  42. }
  43. },
  44. min: -4000000,
  45. max: 4000000
  46. },
  47. plotOptions: {
  48. series: {
  49. stacking: 'normal'
  50. }
  51. },
  52. tooltip: {
  53. formatter: function(){
  54. return '<b>'+ this.series.name +', age '+ this.point.category +'</b><br/>'+
  55. 'Population: '+ Highcharts.numberFormat(Math.abs(this.point.y), 0);
  56. }
  57. },
  58. series: [{
  59. name: 'Male',
  60. data: [-1746181, -1884428, -2089758, -2222362, -2537431, -2507081, -2443179,
  61. -2664537, -3556505, -3680231, -3143062, -2721122, -2229181, -2227768,
  62. -2176300, -1329968, -836804, -354784, -90569, -28367, -3878]
  63. }, {
  64. name: 'Female',
  65. data: [1656154, 1787564, 1981671, 2108575, 2403438, 2366003, 2301402, 2519874,
  66. 3360596, 3493473, 3050775, 2759560, 2304444, 2426504, 2568938, 1785638,
  67. 1447162, 1005011, 330870, 130632, 21208]
  68. }]
  69. });
  70. });
  71. });
  72. </script>
  73. </head>
  74. <body>
  75. <script src="../../js/highcharts.js"></script>
  76. <script src="../../js/modules/exporting.js"></script>
  77. <div id="container" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div>
  78. </body>
  79. </html>