index.htm 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Highmaps Example</title>
  6. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  7. <style type="text/css">
  8. #container {
  9. height: 500px;
  10. min-width: 310px;
  11. max-width: 800px;
  12. margin: 0 auto;
  13. }
  14. .loading {
  15. margin-top: 10em;
  16. text-align: center;
  17. color: gray;
  18. }
  19. </style>
  20. <script type="text/javascript">
  21. $(function () {
  22. // Load the data from a Google Spreadsheet
  23. // https://docs.google.com/a/highsoft.com/spreadsheet/pub?hl=en_GB&hl=en_GB&key=0AoIaUO7wH1HwdFJHaFI4eUJDYlVna3k5TlpuXzZubHc&output=html
  24. Highcharts.data({
  25. googleSpreadsheetKey: '0AoIaUO7wH1HwdFJHaFI4eUJDYlVna3k5TlpuXzZubHc',
  26. // custom handler when the spreadsheet is parsed
  27. parsed: function (columns) {
  28. // Read the columns into the data array
  29. var data = [];
  30. $.each(columns[0], function (i, code) {
  31. data.push({
  32. code: code.toUpperCase(),
  33. value: parseFloat(columns[2][i]),
  34. name: columns[1][i]
  35. });
  36. });
  37. // Initiate the chart
  38. $('#container').highcharts('Map', {
  39. chart : {
  40. borderWidth : 1
  41. },
  42. colors: ['rgba(19,64,117,0.05)', 'rgba(19,64,117,0.2)', 'rgba(19,64,117,0.4)',
  43. 'rgba(19,64,117,0.5)', 'rgba(19,64,117,0.6)', 'rgba(19,64,117,0.8)', 'rgba(19,64,117,1)'],
  44. title : {
  45. text : 'Population density by country (/km²)'
  46. },
  47. mapNavigation: {
  48. enabled: true
  49. },
  50. legend: {
  51. title: {
  52. text: 'Individuals per km²',
  53. style: {
  54. color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
  55. }
  56. },
  57. align: 'left',
  58. verticalAlign: 'bottom',
  59. floating: true,
  60. layout: 'vertical',
  61. valueDecimals: 0,
  62. backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || 'rgba(255, 255, 255, 0.85)',
  63. symbolRadius: 0,
  64. symbolHeight: 14
  65. },
  66. colorAxis: {
  67. dataClasses: [{
  68. to: 3
  69. }, {
  70. from: 3,
  71. to: 10
  72. }, {
  73. from: 10,
  74. to: 30
  75. }, {
  76. from: 30,
  77. to: 100
  78. }, {
  79. from: 100,
  80. to: 300
  81. }, {
  82. from: 300,
  83. to: 1000
  84. }, {
  85. from: 1000
  86. }]
  87. },
  88. series : [{
  89. data : data,
  90. mapData: Highcharts.maps['custom/world'],
  91. joinBy: ['iso-a2', 'code'],
  92. animation: true,
  93. name: 'Population density',
  94. states: {
  95. hover: {
  96. color: '#BADA55'
  97. }
  98. },
  99. tooltip: {
  100. valueSuffix: '/km²'
  101. }
  102. }]
  103. });
  104. },
  105. error: function () {
  106. $('#container').html('<div class="loading">' +
  107. '<i class="icon-frown icon-large"></i> ' +
  108. 'Error loading data from Google Spreadsheets' +
  109. '</div>');
  110. }
  111. });
  112. });
  113. </script>
  114. </head>
  115. <body>
  116. <script src="../../js/highmaps.js"></script>
  117. <script src="../../js/modules/data.js"></script>
  118. <script src="http://code.highcharts.com/mapdata/custom/world.js"></script>
  119. <div id="container">
  120. <div class="loading">
  121. <i class="icon-spinner icon-spin icon-large"></i>
  122. Loading data from Google Spreadsheets...
  123. </div>
  124. </div>
  125. </body>
  126. </html>