map.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1" />
  5. <script src="esl.js"></script>
  6. <script src="config.js"></script>
  7. <script src="lib/jquery.min.js"></script>
  8. <script src="lib/facePrint.js"></script>
  9. </head>
  10. <body>
  11. <style>
  12. html, body, #main {
  13. width: 100%;
  14. height: 100%;
  15. margin: 0;
  16. }
  17. </style>
  18. <div id="main"></div>
  19. <script>
  20. require([
  21. 'echarts',
  22. 'echarts/chart/map',
  23. 'echarts/component/title',
  24. 'echarts/component/legend',
  25. 'echarts/component/visualMap',
  26. 'echarts/component/markPoint',
  27. 'echarts/component/tooltip'
  28. ], function (echarts) {
  29. require(['map/js/china'], function () {
  30. var chart = echarts.init(document.getElementById('main'));
  31. var itemStyle = {
  32. normal:{
  33. borderColor: 'rgba(0, 0, 0, 0.2)'
  34. },
  35. emphasis:{
  36. shadowOffsetX: 0,
  37. shadowOffsetY: 0,
  38. shadowBlur: 20,
  39. borderWidth: 0,
  40. shadowColor: 'rgba(0, 0, 0, 0.5)'
  41. }
  42. };
  43. chart.setOption({
  44. tooltip: {},
  45. title : {
  46. text: 'iphone销量',
  47. subtext: '纯属虚构',
  48. left: 'center'
  49. },
  50. legend: {
  51. orient: 'vertical',
  52. left: 'left',
  53. data:['iphone3','iphone4','iphone5']
  54. },
  55. visualMap: {
  56. min: 0,
  57. max: 1500,
  58. left: 'left',
  59. top: 'bottom',
  60. text:['高','低'], // 文本,默认为数值文本
  61. calculable : true
  62. },
  63. selectedMode: 'single',
  64. series : [
  65. {
  66. name: 'iphone3',
  67. type: 'map',
  68. map: 'china',
  69. itemStyle: itemStyle,
  70. showLegendSymbol: true,
  71. // zoom: 10,
  72. // center: [115.97, 29.71],
  73. roam: true,
  74. markPoint: {
  75. data: [{
  76. coord: [115.97, 29.71]
  77. }]
  78. },
  79. label: {
  80. normal: {
  81. show: true
  82. },
  83. emphasis: {
  84. show: true
  85. }
  86. },
  87. data:[
  88. {name: '北京',value: Math.round(Math.random()*1000)},
  89. {name: '天津',value: Math.round(Math.random()*1000)},
  90. {name: '上海',value: Math.round(Math.random()*1000)},
  91. {name: '重庆',value: Math.round(Math.random()*1000)},
  92. {name: '河北',value: Math.round(Math.random()*1000)},
  93. {name: '河南',value: Math.round(Math.random()*1000)},
  94. {name: '云南',value: Math.round(Math.random()*1000)},
  95. {name: '辽宁',value: Math.round(Math.random()*1000)},
  96. {name: '黑龙江',value: Math.round(Math.random()*1000)},
  97. {name: '湖南',value: Math.round(Math.random()*1000)},
  98. {name: '安徽',value: Math.round(Math.random()*1000)},
  99. {name: '山东',value: Math.round(Math.random()*1000)},
  100. {name: '新疆',value: Math.round(Math.random()*1000)},
  101. {name: '江苏',value: Math.round(Math.random()*1000)},
  102. {name: '浙江',value: Math.round(Math.random()*1000)},
  103. {name: '江西',value: Math.round(Math.random()*1000)},
  104. {name: '湖北',value: Math.round(Math.random()*1000)},
  105. {name: '广西',value: Math.round(Math.random()*1000)},
  106. {name: '甘肃',value: Math.round(Math.random()*1000)},
  107. {name: '山西',value: Math.round(Math.random()*1000)},
  108. {name: '内蒙古',value: Math.round(Math.random()*1000)},
  109. {name: '陕西',value: Math.round(Math.random()*1000)},
  110. {name: '吉林',value: Math.round(Math.random()*1000)},
  111. {name: '福建',value: Math.round(Math.random()*1000)},
  112. {name: '贵州',value: Math.round(Math.random()*1000)},
  113. {name: '广东',value: Math.round(Math.random()*1000)},
  114. {name: '青海',value: Math.round(Math.random()*1000)},
  115. {name: '西藏',value: Math.round(Math.random()*1000)},
  116. {name: '四川',value: Math.round(Math.random()*1000)},
  117. {name: '宁夏',value: Math.round(Math.random()*1000)},
  118. {name: '海南',value: Math.round(Math.random()*1000)},
  119. {name: '台湾',value: Math.round(Math.random()*1000)},
  120. {name: '香港',value: Math.round(Math.random()*1000)},
  121. {name: '澳门',value: Math.round(Math.random()*1000)}
  122. ]
  123. },
  124. {
  125. name: 'iphone4',
  126. type: 'map',
  127. mapType: 'china',
  128. itemStyle: itemStyle,
  129. showLegendSymbol: true,
  130. label: {
  131. normal: {
  132. show: true
  133. },
  134. emphasis: {
  135. show: true
  136. }
  137. },
  138. data:[
  139. {name: '北京',value: Math.round(Math.random()*1000)},
  140. {name: '天津',value: Math.round(Math.random()*1000)},
  141. {name: '上海',value: Math.round(Math.random()*1000)},
  142. {name: '重庆',value: Math.round(Math.random()*1000)},
  143. {name: '河北',value: Math.round(Math.random()*1000)},
  144. {name: '安徽',value: Math.round(Math.random()*1000)},
  145. {name: '新疆',value: Math.round(Math.random()*1000)},
  146. {name: '浙江',value: Math.round(Math.random()*1000)},
  147. {name: '江西',value: Math.round(Math.random()*1000)},
  148. {name: '山西',value: Math.round(Math.random()*1000)},
  149. {name: '内蒙古',value: Math.round(Math.random()*1000)},
  150. {name: '吉林',value: Math.round(Math.random()*1000)},
  151. {name: '福建',value: Math.round(Math.random()*1000)},
  152. {name: '广东',value: Math.round(Math.random()*1000)},
  153. {name: '西藏',value: Math.round(Math.random()*1000)},
  154. {name: '四川',value: Math.round(Math.random()*1000)},
  155. {name: '宁夏',value: Math.round(Math.random()*1000)},
  156. {name: '香港',value: Math.round(Math.random()*1000)},
  157. {name: '澳门',value: Math.round(Math.random()*1000)}
  158. ]
  159. },
  160. {
  161. name: 'iphone5',
  162. type: 'map',
  163. mapType: 'china',
  164. itemStyle: itemStyle,
  165. showLegendSymbol: true,
  166. label: {
  167. normal: {
  168. show: true
  169. },
  170. emphasis: {
  171. show: true
  172. }
  173. },
  174. data:[
  175. {name: '北京',value: Math.round(Math.random()*1000)},
  176. {name: '天津',value: Math.round(Math.random()*1000)},
  177. {name: '上海',value: Math.round(Math.random()*1000)},
  178. {name: '广东',value: Math.round(Math.random()*1000)},
  179. {name: '台湾',value: Math.round(Math.random()*1000)},
  180. {name: '香港',value: Math.round(Math.random()*1000)},
  181. {name: '澳门',value: Math.round(Math.random()*1000)}
  182. ]
  183. }
  184. ]
  185. });
  186. chart.on('click', function (param) {
  187. console.log(param);
  188. });
  189. // setTimeout(function () {
  190. // chart.setOption({
  191. // series: [{
  192. // zoom: 5
  193. // }]
  194. // });
  195. // }, 2000);
  196. });
  197. });
  198. </script>
  199. </body>
  200. </html>