visualMap-pieces.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="esl.js"></script>
  5. <script src="config.js"></script>
  6. </head>
  7. <body>
  8. <style>
  9. html, body, #main {
  10. width: 100%;
  11. height: 100%;
  12. }
  13. </style>
  14. <div id="main"></div>
  15. <script>
  16. require([
  17. 'echarts',
  18. 'echarts/chart/map',
  19. 'echarts/component/legend',
  20. 'echarts/component/grid',
  21. 'echarts/component/visualMap',
  22. 'echarts/component/tooltip',
  23. 'map/js/china'
  24. ], function (echarts) {
  25. var chart = echarts.init(document.getElementById('main'));
  26. option = {
  27. title : {
  28. text: '订单量',
  29. subtext: '纯属虚构',
  30. x:'center'
  31. },
  32. tooltip : {
  33. trigger: 'item'
  34. },
  35. legend: {
  36. orient: 'vertical',
  37. x:'left',
  38. data:['订单量']
  39. },
  40. visualMap: {
  41. // selectedMode: 'single',
  42. pieces: [
  43. {min: 1500},
  44. {min: 900, max: 1500},
  45. {min: 310, max: 1000},
  46. {min: 200, max: 300},
  47. {min: 10, max: 200, label: '10 到 200(自定义label)'},
  48. {value: 123, label: '123(自定义特殊颜色)', color: 'grey'},
  49. {min: 5, max: 5, label: '5(自定义特殊颜色)', color: 'black'},
  50. {max: 5}
  51. ],
  52. color: ['#E0022B', '#E09107', '#A3E00B']
  53. },
  54. toolbox: {
  55. show: true,
  56. orient : 'vertical',
  57. x: 'right',
  58. y: 'center',
  59. feature : {
  60. mark : {show: true},
  61. dataView : {show: true, readOnly: false},
  62. restore : {show: true},
  63. saveAsImage : {show: true}
  64. }
  65. },
  66. roamController: {
  67. show: true,
  68. x: 'right',
  69. mapTypeControl: {
  70. 'china': true
  71. }
  72. },
  73. series : [
  74. {
  75. name: '订单量',
  76. type: 'map',
  77. mapType: 'china',
  78. roam: false,
  79. itemStyle:{
  80. normal:{
  81. label:{
  82. show:true,
  83. textStyle: {
  84. color: "rgb(249, 249, 249)"
  85. }
  86. }
  87. },
  88. emphasis:{label:{show:true}}
  89. },
  90. data:[
  91. {name: '北京',value: 5},
  92. {name: '天津',value: Math.round(Math.random()*2000)},
  93. {name: '上海',value: Math.round(Math.random()*2000)},
  94. {name: '重庆',value: Math.round(Math.random()*2000)},
  95. {name: '河北',value: 0},
  96. {name: '河南',value: Math.round(Math.random()*2000)},
  97. {name: '云南',value: 123},
  98. {name: '辽宁',value: 305},
  99. {name: '黑龙江',value: Math.round(Math.random()*2000)},
  100. {name: '湖南',value: 200},
  101. {name: '安徽',value: Math.round(Math.random()*2000)},
  102. {name: '山东',value: Math.round(Math.random()*2000)},
  103. {name: '新疆',value: Math.round(Math.random()*2000)},
  104. {name: '江苏',value: Math.round(Math.random()*2000)},
  105. {name: '浙江',value: Math.round(Math.random()*2000)},
  106. {name: '江西',value: Math.round(Math.random()*2000)},
  107. {name: '湖北',value: Math.round(Math.random()*2000)},
  108. {name: '广西',value: Math.round(Math.random()*2000)},
  109. {name: '甘肃',value: Math.round(Math.random()*2000)},
  110. {name: '山西',value: Math.round(Math.random()*2000)},
  111. {name: '内蒙古',value: Math.round(Math.random()*2000)},
  112. {name: '陕西',value: Math.round(Math.random()*2000)},
  113. {name: '吉林',value: Math.round(Math.random()*2000)},
  114. {name: '福建',value: Math.round(Math.random()*2000)},
  115. {name: '贵州',value: Math.round(Math.random()*2000)},
  116. {name: '广东',value: Math.round(Math.random()*2000)},
  117. {name: '青海',value: Math.round(Math.random()*2000)},
  118. {name: '西藏',value: Math.round(Math.random()*2000)},
  119. {name: '四川',value: Math.round(Math.random()*2000)},
  120. {name: '宁夏',value: Math.round(Math.random()*2000)},
  121. {name: '海南',value: Math.round(Math.random()*2000)},
  122. {name: '台湾',value: Math.round(Math.random()*2000)},
  123. {name: '香港',value: Math.round(Math.random()*2000)},
  124. {name: '澳门',value: Math.round(Math.random()*2000)}
  125. ]
  126. }
  127. ]
  128. };
  129. chart.setOption(option);
  130. })
  131. </script>
  132. </body>
  133. </html>