map.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <!DOCTYPE html>
  2. <head>
  3. <meta charset="utf-8">
  4. <title>ECharts</title>
  5. </head>
  6. <body>
  7. <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
  8. <div id="main" style="height:800px"></div>
  9. <!-- ECharts单文件引入 -->
  10. <script src="https://www.shadowsocks5.com/build/dist/echarts.js"></script>
  11. <script type="text/javascript">
  12. // 路径配置
  13. require.config({
  14. paths: {
  15. echarts: 'https://www.shadowsocks5.com/build/dist'
  16. }
  17. });
  18. // 使用
  19. require(
  20. [
  21. 'echarts',
  22. 'echarts/chart/line',
  23. 'echarts/chart/bar',
  24. 'echarts/chart/scatter',
  25. 'echarts/chart/k',
  26. 'echarts/chart/pie',
  27. 'echarts/chart/radar',
  28. 'echarts/chart/force',
  29. 'echarts/chart/chord',
  30. 'echarts/chart/gauge',
  31. 'echarts/chart/funnel',
  32. 'echarts/chart/eventRiver',
  33. 'echarts/chart/venn',
  34. 'echarts/chart/treemap',
  35. 'echarts/chart/tree',
  36. 'echarts/chart/wordCloud',
  37. 'echarts/chart/heatmap',
  38. 'echarts/chart/map'
  39. ],
  40. function (ec) {
  41. // 基于准备好的dom,初始化echarts图表
  42. var myChart = ec.init(document.getElementById('main'));
  43. var option = {
  44. dataRange: {
  45. min: 0,
  46. max: 3000,
  47. orient: 'horizontal',
  48. splitNumber: 30,
  49. color:['#31A829','#D8F6D5'],
  50. //color:['#1556A1','#136BD4','#6C98D5','#9FCCFF','#DCECFF'],
  51. x: 'right',
  52. y: 'top',
  53. calculable : true
  54. },
  55. title: {
  56. text: '用户分布图',
  57. left: 'center'
  58. },
  59. series : [
  60. {
  61. name: 'Map',
  62. type: 'map',
  63. mapType: 'china',
  64. label: {
  65. normal: {
  66. show: true
  67. },
  68. emphasis: {
  69. show: true
  70. }
  71. },
  72. label: {
  73. normal: {
  74. show: true
  75. },
  76. emphasis: {
  77. show: true
  78. }
  79. },
  80. mapLocation: {
  81. x : 'left',
  82. y : 'top',
  83. height : 500
  84. },
  85. selectedMode: 'multiple',
  86. data:[<!--{foreach($china as $k1=>$v1)}-->{
  87. name: '<!--{$v1}-->',
  88. value: <!--{$value[$k1]}-->,
  89. },<!--{/foreach}-->
  90. ],
  91. }
  92. ],
  93. tooltip : {
  94. trigger: 'item',
  95. formatter:'{b}:{c}'
  96. },
  97. };
  98. // 为echarts对象加载数据
  99. myChart.setOption(option);
  100. }
  101. );
  102. </script>
  103. </body>