地图

china.js
echarts.min.js

map.html

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Document</title>
  6. </head>
  7. <body>
  8. <!-- ECharts准备一个具备大小(宽高)的Dom -->
  9. <div id="main" style="width: 1000px;height:800px;"></div>
  10. <script src="./js/echarts.min.js"></script>
  11. <script src="./js/china.js"></script>
  12. <script type="text/javascript">
  13. var myChart = echarts.init(document.getElementById('main'), 'shine');
  14. function randomData() {
  15. return Math.round(Math.random() * 1000);
  16. }
  17. option = {
  18. title: {
  19. text: 'iphone销量',
  20. subtext: '纯属虚构',
  21. left: 'center'
  22. },
  23. tooltip: {
  24. trigger: 'item'
  25. },
  26. legend: {
  27. orient: 'vertical',
  28. left: 'left',
  29. data: ['iphone3', 'iphone4', 'iphone5']
  30. },
  31. visualMap: {
  32. min: 0,
  33. max: 2500,
  34. left: 'left',
  35. top: 'bottom',
  36. text: ['高', '低'], // 文本,默认为数值文本
  37. calculable: true
  38. },
  39. toolbox: {
  40. show: false,
  41. orient: 'vertical',
  42. left: 'right',
  43. top: 'center',
  44. feature: {
  45. dataView: {
  46. readOnly: false
  47. },
  48. restore: {},
  49. saveAsImage: {}
  50. }
  51. },
  52. series: [{
  53. itemStyle: {
  54. normal: {
  55. color: function (params) {
  56. var colorList = [
  57. '#C1232B', '#B5C334', '#FCCE10', '#E87C25', '#27727B',
  58. '#FE8463', '#9BCA63', '#FAD860', '#F3A43B', '#60C0DD',
  59. '#D7504B', '#C6E579', '#F4E001', '#F0805A', '#26C0C0'
  60. ];
  61. return colorList[params.dataIndex]
  62. },
  63. }
  64. },
  65. name: 'iphone3',
  66. type: 'map',
  67. mapType: 'china',
  68. roam: false,
  69. label: {
  70. normal: {
  71. show: true
  72. },
  73. emphasis: {
  74. show: true
  75. }
  76. },
  77. data: [{
  78. name: '北京',
  79. value: randomData()
  80. },
  81. {
  82. name: '天津',
  83. value: randomData()
  84. },
  85. {
  86. name: '上海',
  87. value: randomData()
  88. },
  89. {
  90. name: '重庆',
  91. value: randomData()
  92. },
  93. {
  94. name: '河北',
  95. value: randomData()
  96. },
  97. {
  98. name: '河南',
  99. value: randomData()
  100. },
  101. {
  102. name: '云南',
  103. value: randomData()
  104. },
  105. {
  106. name: '辽宁',
  107. value: randomData()
  108. },
  109. {
  110. name: '黑龙江',
  111. value: randomData()
  112. },
  113. {
  114. name: '湖南',
  115. value: randomData()
  116. },
  117. {
  118. name: '安徽',
  119. value: randomData()
  120. },
  121. {
  122. name: '山东',
  123. value: randomData()
  124. },
  125. {
  126. name: '新疆',
  127. value: randomData()
  128. },
  129. {
  130. name: '江苏',
  131. value: randomData()
  132. },
  133. {
  134. name: '浙江',
  135. value: randomData()
  136. },
  137. {
  138. name: '江西',
  139. value: randomData()
  140. },
  141. {
  142. name: '湖北',
  143. value: randomData()
  144. },
  145. {
  146. name: '广西',
  147. value: randomData()
  148. },
  149. {
  150. name: '甘肃',
  151. value: randomData()
  152. },
  153. {
  154. name: '山西',
  155. value: randomData()
  156. },
  157. {
  158. name: '内蒙古',
  159. value: randomData()
  160. },
  161. {
  162. name: '陕西',
  163. value: randomData()
  164. },
  165. {
  166. name: '吉林',
  167. value: randomData()
  168. },
  169. {
  170. name: '福建',
  171. value: randomData()
  172. },
  173. {
  174. name: '贵州',
  175. value: randomData()
  176. },
  177. {
  178. name: '广东',
  179. value: randomData()
  180. },
  181. {
  182. name: '青海',
  183. value: randomData()
  184. },
  185. {
  186. name: '西藏',
  187. value: randomData()
  188. },
  189. {
  190. name: '四川',
  191. value: randomData()
  192. },
  193. {
  194. name: '宁夏',
  195. value: randomData()
  196. },
  197. {
  198. name: '海南',
  199. value: randomData()
  200. },
  201. {
  202. name: '台湾',
  203. value: randomData()
  204. },
  205. {
  206. name: '香港',
  207. value: randomData()
  208. },
  209. {
  210. name: '澳门',
  211. value: randomData()
  212. }
  213. ]
  214. }]
  215. };
  216. myChart.setOption(option);
  217. </script>
  218. </body>
  219. </html>

image.png