map.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1" />
  5. <script src="lib/esl.js"></script>
  6. <script src="lib/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. rotate: 40,
  83. formatter: '{b}:{value|{c}}',
  84. // position: 'inside',
  85. backgroundColor: '#fff',
  86. padding: [3, 5],
  87. borderRadius: 3,
  88. borderWidth: 1,
  89. borderColor: 'rgba(0,0,0,0.5)',
  90. color: '#777',
  91. rich: {
  92. value: {
  93. color: '#019D2D',
  94. fontSize: 14,
  95. // fontWeight: 'bold'
  96. // textBorderWidth: 2,
  97. // textBorderColor: '#000'
  98. }
  99. }
  100. },
  101. emphasis: {
  102. show: true
  103. }
  104. },
  105. data:[
  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. {name: '湖北',value: Math.round(Math.random()*1000)},
  123. {name: '广西',value: Math.round(Math.random()*1000)},
  124. {name: '甘肃',value: Math.round(Math.random()*1000)},
  125. {name: '山西',value: Math.round(Math.random()*1000)},
  126. {name: '内蒙古',value: Math.round(Math.random()*1000)},
  127. {name: '陕西',value: Math.round(Math.random()*1000)},
  128. {name: '吉林',value: Math.round(Math.random()*1000)},
  129. {name: '福建',value: Math.round(Math.random()*1000)},
  130. {name: '贵州',value: Math.round(Math.random()*1000)},
  131. {name: '广东',value: Math.round(Math.random()*1000)},
  132. {name: '青海',value: Math.round(Math.random()*1000)},
  133. {name: '西藏',value: Math.round(Math.random()*1000)},
  134. {name: '四川',value: Math.round(Math.random()*1000)},
  135. {name: '宁夏',value: Math.round(Math.random()*1000)},
  136. {name: '海南',value: Math.round(Math.random()*1000)},
  137. {name: '台湾',value: Math.round(Math.random()*1000)},
  138. {name: '香港',value: Math.round(Math.random()*1000)},
  139. {name: '澳门',value: Math.round(Math.random()*1000)}
  140. ]
  141. },
  142. {
  143. name: 'iphone4',
  144. type: 'map',
  145. mapType: 'china',
  146. itemStyle: itemStyle,
  147. showLegendSymbol: true,
  148. label: {
  149. normal: {
  150. show: true
  151. },
  152. emphasis: {
  153. show: true
  154. }
  155. },
  156. data:[
  157. {name: '北京',value: Math.round(Math.random()*1000)},
  158. {name: '天津',value: Math.round(Math.random()*1000)},
  159. {name: '上海',value: Math.round(Math.random()*1000)},
  160. {name: '重庆',value: Math.round(Math.random()*1000)},
  161. {name: '河北',value: Math.round(Math.random()*1000)},
  162. {name: '安徽',value: Math.round(Math.random()*1000)},
  163. {name: '新疆',value: Math.round(Math.random()*1000)},
  164. {name: '浙江',value: Math.round(Math.random()*1000)},
  165. {name: '江西',value: Math.round(Math.random()*1000)},
  166. {name: '山西',value: Math.round(Math.random()*1000)},
  167. {name: '内蒙古',value: Math.round(Math.random()*1000)},
  168. {name: '吉林',value: Math.round(Math.random()*1000)},
  169. {name: '福建',value: Math.round(Math.random()*1000)},
  170. {name: '广东',value: Math.round(Math.random()*1000)},
  171. {name: '西藏',value: Math.round(Math.random()*1000)},
  172. {name: '四川',value: Math.round(Math.random()*1000)},
  173. {name: '宁夏',value: Math.round(Math.random()*1000)},
  174. {name: '香港',value: Math.round(Math.random()*1000)},
  175. {name: '澳门',value: Math.round(Math.random()*1000)}
  176. ]
  177. },
  178. {
  179. name: 'iphone5',
  180. type: 'map',
  181. mapType: 'china',
  182. itemStyle: itemStyle,
  183. showLegendSymbol: true,
  184. label: {
  185. normal: {
  186. show: true
  187. },
  188. emphasis: {
  189. show: true
  190. }
  191. },
  192. data:[
  193. {name: '北京',value: Math.round(Math.random()*1000)},
  194. {name: '天津',value: Math.round(Math.random()*1000)},
  195. {name: '上海',value: Math.round(Math.random()*1000)},
  196. {name: '广东',value: Math.round(Math.random()*1000)},
  197. {name: '台湾',value: Math.round(Math.random()*1000)},
  198. {name: '香港',value: Math.round(Math.random()*1000)},
  199. {name: '澳门',value: Math.round(Math.random()*1000)}
  200. ]
  201. }
  202. ]
  203. });
  204. chart.on('click', function (param) {
  205. console.log(param);
  206. });
  207. // setTimeout(function () {
  208. // chart.setOption({
  209. // series: [{
  210. // zoom: 5
  211. // }]
  212. // });
  213. // }, 2000);
  214. });
  215. });
  216. </script>
  217. </body>
  218. </html>