Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.16 KB | None | 0 0
  1. <!-- jQuery -->
  2. <script type="text/javascript" src="/js/jquery.min.js"></script>
  3. <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
  4.  
  5. <!-- JQVMap -->
  6. <script type="text/javascript" src="/newsite/js/jvectormap/jquery.vmap.min.js"></script>
  7. <!--<script type="text/javascript" src="/newsite/js/jvectormap/jquery.vmap.js"></script>-->
  8. <script type="text/javascript" src="/newsite/js/jvectormap/jquery.vmap.world.js"></script>
  9. <script type="text/javascript" src="/newsite/js/jvectormap/jquery.vmap.sampledata.js"></script>
  10. <script type="text/javascript" src="/newsite/js/jvectormap/gdp-data.js"></script>
  11.  
  12. <div id="vmap" style="width: 600px; height: 400px;"></div>
  13.  
  14. var accountbalanceData = {
  15. "AF": -1.086,
  16. "AL": -13.237,
  17. "DZ": 9.984,
  18. "AO": 9.717,
  19. "AG": -13.686,
  20. "AR": -0.701,
  21. "AM": -11.043,
  22. "AU": -4.614,
  23. "AT": 1.374,
  24. "AZ": 21.789,
  25. ...};
  26.  
  27. var gdpData = {
  28. "OM": 53.78,
  29. "PK": 174.79,
  30. "PA": 27.2,
  31. "PG": 8.81,
  32. "PY": 17.17,
  33. "PE": 153.55,
  34. "PH": 189.06,
  35. "PL": 438.88,
  36. "PT": 223.7,
  37. ...};
  38.  
  39. .jqvmap-label
  40. {
  41. position: absolute;
  42. display: none;
  43. -webkit-border-radius: 3px;
  44. -moz-border-radius: 3px;
  45. border-radius: 3px;
  46. background: #292929;
  47. color: white;
  48. font-family: sans-serif, Verdana;
  49. font-size: smaller;
  50. padding: 3px;
  51. }
  52.  
  53. .jqvmap-zoomin, .jqvmap-zoomout
  54. {
  55. position: absolute;
  56. left: 10px;
  57. -webkit-border-radius: 3px;
  58. -moz-border-radius: 3px;
  59. border-radius: 3px;
  60. background: #000000;
  61. padding: 3px;
  62. color: white;
  63. width: 10px;
  64. height: 10px;
  65. cursor: pointer;
  66. line-height: 10px;
  67. text-align: center;
  68. }
  69.  
  70. .jqvmap-zoomin
  71. {
  72. top: 10px;
  73. }
  74.  
  75. .jqvmap-zoomout
  76. {
  77. top: 30px;
  78. }
  79.  
  80. .jqvmap-region
  81. {
  82. cursor: pointer;
  83. }
  84.  
  85. .jqvmap-ajax_response
  86. {
  87. width: 100%;
  88. height: 500px;
  89. }
  90.  
  91. <script>
  92. $(function(){
  93. var max = 0,
  94. min = Number.MAX_VALUE,
  95. cc,
  96. startColor = [200, 238, 255],
  97. endColor = [0, 100, 145],
  98. mycolors = {},
  99. hex;
  100.  
  101. //find maximum and minimum values
  102. for (cc in sample_data)
  103. {
  104. if (parseFloat(sample_data[cc]) > max)
  105. {
  106. max = parseFloat(sample_data[cc]);
  107. }
  108. if (parseFloat(sample_data[cc]) < min)
  109. {
  110. min = parseFloat(sample_data[cc]);
  111. }
  112. };
  113.  
  114. //set colors according to values of GDP
  115. for (cc in sample_data)
  116. {
  117. if (sample_data[cc] > 0)
  118. {
  119. mycolors[cc] = '#';
  120. for (var i = 0; i<3; i++)
  121. {
  122. hex = Math.round(startColor[i]
  123. + (endColor[i]
  124. - startColor[i])
  125. * (gdpData[cc] / (max - min))).toString(16);
  126.  
  127. if (hex.length == 1)
  128. {
  129. hex = '0'+hex;
  130. }
  131.  
  132. mycolors[cc] += (hex.length == 1 ? '0' : '') + hex;
  133. }
  134. }
  135. };
  136.  
  137. jQuery('#vmap').vectorMap({
  138. map: 'world_en',
  139. //backgroundColor: '#a5bfdd', //Color of the background ("Ocean's")
  140. borderColor: '#818181', //Color of the country borders
  141. borderOpacity: 0.15, //Border thickness
  142. borderWidth: 1,
  143. //color: 'white', //Country color
  144. series: {
  145. regions: [{
  146. values: sample_data,
  147. scale: ['#C8EEFF', '#0071A4'],
  148. normalizeFunction: 'polynomial',
  149. }]
  150. },
  151. colors: mycolors,
  152. hoverOpacity: 0.7,
  153. hoverColor: false,
  154. //scaleColors: ['#b6d6ff', '#005ace'],
  155. onRegionClick: function(element, code, region)
  156. {
  157. var message = 'You clicked "'
  158. + region
  159. + '" which has the code: '
  160. + code.toUpperCase();
  161.  
  162. alert(message);
  163. }
  164. });
  165. });
  166. </script>
  167.  
  168. $('#vmap').vectorMap({
  169. map: 'world_mill_en',
  170. regionStyle: //your initial values (including hover)
  171. series: {
  172. regions: [{
  173. values: accountbalanceData,
  174. scale: ['#C8EEFF', '#0071A4'],
  175. normalizeFunction: 'polynomial',
  176. }]
  177. },
  178. onRegionClick: function(element, code, region)
  179. {
  180. var message = 'You clicked "'
  181. + region
  182. + '" which has the code: '
  183. + code.toUpperCase();
  184.  
  185. alert(message);
  186. }
  187. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement