index.htm 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. width: 800px;
  11. margin: 0 auto;
  12. }
  13. .highcharts-tooltip>span {
  14. padding: 10px;
  15. white-space: normal !important;
  16. width: 200px;
  17. }
  18. .loading {
  19. margin-top: 10em;
  20. text-align: center;
  21. color: gray;
  22. }
  23. .f32 .flag {
  24. vertical-align: middle !important;
  25. }
  26. </style>
  27. <script type="text/javascript">
  28. $(function () {
  29. $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=world-population-density.json&callback=?', function (data) {
  30. // Add lower case codes to the data set for inclusion in the tooltip.pointFormat
  31. $.each(data, function () {
  32. this.flag = this.code.replace('UK', 'GB').toLowerCase();
  33. });
  34. // Initiate the chart
  35. $('#container').highcharts('Map', {
  36. title: {
  37. text: 'Fixed tooltip with HTML'
  38. },
  39. legend: {
  40. title: {
  41. text: 'Population density per km²',
  42. style: {
  43. color: (Highcharts.theme && Highcharts.theme.textColor) || 'black'
  44. }
  45. }
  46. },
  47. mapNavigation: {
  48. enabled: true,
  49. buttonOptions: {
  50. verticalAlign: 'bottom'
  51. }
  52. },
  53. tooltip: {
  54. backgroundColor: 'none',
  55. borderWidth: 0,
  56. shadow: false,
  57. useHTML: true,
  58. padding: 0,
  59. pointFormat: '<span class="f32"><span class="flag {point.flag}"></span></span>'
  60. + ' {point.name}: <b>{point.value}</b>/km²',
  61. positioner: function () {
  62. return { x: 0, y: 250 };
  63. }
  64. },
  65. colorAxis: {
  66. min: 1,
  67. max: 1000,
  68. type: 'logarithmic'
  69. },
  70. series : [{
  71. data : data,
  72. mapData: Highcharts.maps['custom/world'],
  73. joinBy: ['iso-a2', 'code'],
  74. name: 'Population density',
  75. states: {
  76. hover: {
  77. color: '#BADA55'
  78. }
  79. }
  80. }]
  81. });
  82. });
  83. });
  84. </script>
  85. </head>
  86. <body>
  87. <script src="../../js/highmaps.js"></script>
  88. <script src="../../js/modules/data.js"></script>
  89. <script src="../../js/modules/exporting.js"></script>
  90. <script src="http://code.highcharts.com/mapdata/custom/world.js"></script>
  91. <!-- Flag sprites service provided by Martijn Lafeber, https://github.com/lafeber/world-flags-sprite/blob/master/LICENSE -->
  92. <link rel="stylesheet" type="text/css" href="http://cloud.github.com/downloads/lafeber/world-flags-sprite/flags32.css" />
  93. <div id="container"></div>
  94. </body>
  95. </html>