index.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>ECharts</title>
  6. </head>
  7. <body>
  8. <!--Step:1 Prepare a dom for ECharts which (must) has size (width & hight)-->
  9. <!--Step:1 为ECharts准备一个具备大小(宽高)的Dom-->
  10. <div id="main" style="height:500px;border:1px solid #ccc;padding:10px;"></div>
  11. <div id="mainMap" style="height:500px;border:1px solid #ccc;padding:10px;"></div>
  12. <!--Step:2 Import echarts-all.js-->
  13. <!--Step:2 引入echarts-all.js-->
  14. <script src="js/echarts-all.js"></script>
  15. <script type="text/javascript">
  16. // Step:3 echarts & zrender as a Global Interface by the echarts-plain.js.
  17. // Step:3 echarts和zrender被echarts-plain.js写入为全局接口
  18. var myChart = echarts.init(document.getElementById('main'));
  19. myChart.setOption({
  20. tooltip : {
  21. trigger: 'axis'
  22. },
  23. legend: {
  24. data:['蒸发量','降水量']
  25. },
  26. toolbox: {
  27. show : true,
  28. feature : {
  29. mark : {show: true},
  30. dataView : {show: true, readOnly: false},
  31. magicType : {show: true, type: ['line', 'bar']},
  32. restore : {show: true},
  33. saveAsImage : {show: true}
  34. }
  35. },
  36. calculable : true,
  37. xAxis : [
  38. {
  39. type : 'category',
  40. data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
  41. }
  42. ],
  43. yAxis : [
  44. {
  45. type : 'value',
  46. splitArea : {show : true}
  47. }
  48. ],
  49. series : [
  50. {
  51. name:'蒸发量',
  52. type:'bar',
  53. data:[2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]
  54. },
  55. {
  56. name:'降水量',
  57. type:'bar',
  58. data:[2.6, 5.9, 9.0, 26.4, 28.7, 70.7, 175.6, 182.2, 48.7, 18.8, 6.0, 2.3]
  59. }
  60. ]
  61. });
  62. // --- 地图 ---
  63. var myChart2 = echarts.init(document.getElementById('mainMap'));
  64. myChart2.setOption({
  65. tooltip : {
  66. trigger: 'item',
  67. formatter: '{b}'
  68. },
  69. series : [
  70. {
  71. name: '中国',
  72. type: 'map',
  73. mapType: 'china',
  74. selectedMode : 'multiple',
  75. itemStyle:{
  76. normal:{label:{show:true}},
  77. emphasis:{label:{show:true}}
  78. },
  79. data:[
  80. {name:'广东',selected:true}
  81. ]
  82. }
  83. ]
  84. });
  85. </script>
  86. </body>
  87. </html>