bar-overflow-time-plot.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="lib/esl.js"></script>
  5. <script src="lib/config.js"></script>
  6. <script src="lib/jquery.min.js"></script>
  7. <script src="lib/facePrint.js"></script>
  8. <script src="lib/testHelper.js"></script>
  9. <meta name="viewport" content="width=device-width, initial-scale=1" />
  10. </head>
  11. <body>
  12. <style>
  13. h1 {
  14. line-height: 60px;
  15. height: 60px;
  16. background: #146402;
  17. text-align: center;
  18. font-weight: bold;
  19. color: #eee;
  20. font-size: 14px;
  21. }
  22. .chart {
  23. height: 600px;
  24. }
  25. </style>
  26. <h1>
  27. <input type="button" onclick="testHelper.setURLParam(['cn', 'en'], 'cn')" value="CN"/>
  28. <input type="button" onclick="testHelper.setURLParam(['cn', 'en'], 'en')" value="EN"/>
  29. </h1>
  30. <div id="main" class="chart"></div>
  31. <script>
  32. require(
  33. (testHelper.hasURLParam('en')
  34. ? [
  35. 'echarts',
  36. 'echarts/lang/en',
  37. ]
  38. : [
  39. 'echarts'
  40. ]
  41. ).concat(
  42. [
  43. // 'echarts/chart/bar',
  44. // 'echarts/chart/line',
  45. // 'echarts/component/legend',
  46. // 'echarts/component/graphic',
  47. // 'echarts/component/grid',
  48. // 'echarts/component/tooltip',
  49. // 'echarts/component/brush',
  50. // 'echarts/component/toolbox',
  51. // 'echarts/component/title',
  52. // 'zrender/vml/vml'
  53. ]
  54. ),
  55. function (echarts) {
  56. var chart = echarts.init(document.getElementById('main'));
  57. var data1 = [[new Date(1498258800000), 10], [new Date(1498345200000), 15], [new Date(1498431600000), 15], [new Date(1498518000000), 15]];
  58. var data2 = [[new Date(1498258800000), 15], [new Date(1498345200000), 20], [new Date(1498431600000), 15], [new Date(1498518000000), 15]];
  59. var itemStyle = {
  60. normal: {
  61. barBorderRadius: 5,
  62. label: {
  63. show: true,
  64. position: 'outside'
  65. }
  66. },
  67. emphasis: {
  68. label: {
  69. position: 'outside'
  70. },
  71. barBorderColor: '#fff',
  72. barBorderWidth: 1,
  73. shadowBlur: 10,
  74. shadowOffsetX: 0,
  75. shadowOffsetY: 0,
  76. shadowColor: 'rgba(0,0,0,0.5)'
  77. }
  78. };
  79. chart.setOption({
  80. backgroundColor: '#eee',
  81. title: {
  82. text: '酒吧在时间轴上',
  83. padding: 20
  84. },
  85. legend: {
  86. left: 150,
  87. inactiveColor: '#abc',
  88. borderWidth: 1,
  89. selected: {
  90. // 'bar': false
  91. },
  92. // orient: 'vertical',
  93. // x: 'right',
  94. // y: 'bottom',
  95. align: 'left',
  96. tooltip: {
  97. show: true
  98. }
  99. },
  100. xAxis: {
  101. type: 'time',
  102. name: '横轴',
  103. },
  104. yAxis: {
  105. // axisLabel: {
  106. // show: false
  107. // },
  108. axisTick: {
  109. show: false
  110. },
  111. splitArea: {
  112. show: false
  113. }
  114. },
  115. series: [{
  116. name: 'bar',
  117. type: 'bar',
  118. data: data1
  119. }, {
  120. name: 'bar2',
  121. type: 'bar',
  122. data: data2
  123. }]
  124. });
  125. chart.on('click', function (params) {
  126. console.log(params);
  127. });
  128. chart.on('legendselectchanged', function (params) {
  129. chart.setOption({
  130. // title: {
  131. // },
  132. graphic: [{
  133. type: 'circle',
  134. shape: {
  135. cx: 100,
  136. cy: 100,
  137. r: 20,
  138. }
  139. }]
  140. });
  141. });
  142. window.onresize = chart.resize;
  143. }
  144. );
  145. </script>
  146. </body>
  147. </html>