bar2.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="esl.js"></script>
  5. <script src="config.js"></script>
  6. <meta name="viewport" content="width=device-width, initial-scale=1" />
  7. </head>
  8. <body>
  9. <style>
  10. html, body, #main {
  11. width: 100%;
  12. height: 100%;
  13. margin: 0;
  14. }
  15. #main {
  16. width: 1000px;
  17. background: #fff;
  18. }
  19. </style>
  20. <div id="main"></div>
  21. <script>
  22. require([
  23. 'echarts',
  24. 'echarts/chart/bar',
  25. 'echarts/component/legend',
  26. 'echarts/component/grid',
  27. 'echarts/component/tooltip',
  28. 'echarts/component/markLine'
  29. ], function (echarts) {
  30. var chart = echarts.init(document.getElementById('main'), null, {
  31. renderer: 'canvas'
  32. });
  33. chart.setOption({
  34. tooltip : {
  35. trigger: 'axis',
  36. axisPointer : { // 坐标轴指示器,坐标轴触发有效
  37. type : 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  38. }
  39. },
  40. legend: {
  41. data:['直接访问','邮件营销','联盟广告','视频广告','搜索引擎','百度','谷歌','必应','其他']
  42. },
  43. toolbox: {
  44. show : true,
  45. orient: 'vertical',
  46. left: 'right',
  47. top: 'center',
  48. feature : {
  49. mark : {show: true},
  50. dataView : {show: true, readOnly: false},
  51. magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
  52. restore : {show: true},
  53. saveAsImage : {show: true}
  54. }
  55. },
  56. calculable : true,
  57. xAxis : [
  58. {
  59. type : 'category',
  60. data : ['周一','周二','周三','周四','周五','周六','周日']
  61. }
  62. ],
  63. yAxis : [
  64. {
  65. type : 'value'
  66. }
  67. ],
  68. series : [
  69. {
  70. name:'直接访问',
  71. type:'bar',
  72. data:[320, 332, 301, 334, 390, 330, 320]
  73. },
  74. {
  75. name:'邮件营销',
  76. type:'bar',
  77. stack: '广告',
  78. data:[120, 132, 101, 134, 90, 230, 210]
  79. },
  80. {
  81. name:'联盟广告',
  82. type:'bar',
  83. stack: '广告',
  84. data:[220, 182, 191, 234, 290, 330, 310]
  85. },
  86. {
  87. name:'视频广告',
  88. type:'bar',
  89. stack: '广告',
  90. data:[150, 232, 201, 154, 190, 330, 410]
  91. },
  92. {
  93. name:'搜索引擎',
  94. type:'bar',
  95. data:[862, 1018, 964, 1026, 1679, 1600, 1570],
  96. markLine : {
  97. itemStyle:{
  98. normal:{
  99. label: {
  100. formatter: function (params) {
  101. console.log(params);
  102. }
  103. },
  104. lineStyle:{
  105. type: 'dashed'
  106. }
  107. }
  108. },
  109. data : [
  110. [{type : 'min'}, {type : 'max'}]
  111. ]
  112. }
  113. },
  114. {
  115. name:'百度',
  116. type:'bar',
  117. barWidth : 5,
  118. stack: '搜索引擎',
  119. data:[620, 732, 701, 734, 1090, 1130, 1120]
  120. },
  121. {
  122. name:'谷歌',
  123. type:'bar',
  124. stack: '搜索引擎',
  125. data:[120, 132, 101, 134, 290, 230, 220]
  126. },
  127. {
  128. name:'必应',
  129. type:'bar',
  130. stack: '搜索引擎',
  131. data:[60, 72, 71, 74, 190, 130, 110]
  132. },
  133. {
  134. name:'其他',
  135. type:'bar',
  136. stack: '搜索引擎',
  137. data:[62, 82, 91, 84, 109, 110, 120]
  138. }
  139. ]
  140. });
  141. });
  142. </script>
  143. </body>
  144. </html>