touch-test.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <!DOCTYPE>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <script src="esl.js"></script>
  6. <script src="config.js"></script>
  7. <script src="lib/facePrint.js"></script>
  8. <meta name="viewport" content="width=device-width, initial-scale=1" />
  9. <link rel="stylesheet" href="reset.css">
  10. </head>
  11. <body>
  12. <style>
  13. html {
  14. background: #eee;
  15. }
  16. #main-block {
  17. /* See https://github.com/ecomfe/echarts/issues/3233#issuecomment-220269663 */
  18. height: 1000px;
  19. padding: 0;
  20. top: 100px;
  21. left: 30px;
  22. }
  23. #buttons {
  24. z-index: 9999;
  25. position: fixed;
  26. right: 5px;
  27. bottom: 5px;
  28. }
  29. #above {
  30. border: 40px solid #aaa;
  31. height: 400px;
  32. margin: 10px;
  33. color: #aaa;
  34. }
  35. </style>
  36. <style>
  37. </style>
  38. <div id="buttons">
  39. <button id="switchAbove" onclick="addAbove();">Remove Above</botton>
  40. <button id="switchCSSPosition" onclick="switchCSSPosition();">To Fixed</botton>
  41. </div>
  42. <div id="above">Pinch grid, zoom should be normal.</div>
  43. <div id="main-block" style="position:relative"><div id="main" style="position:relative"></div></div>
  44. <script>
  45. function addAbove() {
  46. var aboveEl = document.getElementById('above');
  47. var btn = document.getElementById('switchAbove');
  48. if (aboveEl.style.display === 'none') {
  49. aboveEl.style.display = 'block';
  50. btn.innerHTML = 'Remove Above';
  51. }
  52. else {
  53. aboveEl.style.display = 'none';
  54. btn.innerHTML = 'Add Above';
  55. }
  56. }
  57. function switchCSSPosition() {
  58. var mainBlockEl = document.getElementById('main-block');
  59. var btn = document.getElementById('switchCSSPosition');
  60. if (mainBlockEl.style.position === 'fixed') {
  61. mainBlockEl.style.position = 'relative';
  62. mainBlockEl.style.top = '0';
  63. btn.innerHTML = 'To Fixed';
  64. }
  65. else {
  66. mainBlockEl.style.position = 'fixed';
  67. mainBlockEl.style.top = '-400px';
  68. btn.innerHTML = 'To relative';
  69. }
  70. }
  71. for (var i = 0; i < 1000; i++) {
  72. var d = document.createElement('div');
  73. d.innerHTML = i;
  74. document.body.appendChild(d);
  75. }
  76. var echarts;
  77. var chart;
  78. var myChart;
  79. require([
  80. 'echarts',
  81. 'echarts/chart/line',
  82. 'echarts/chart/bar',
  83. 'echarts/component/legend',
  84. 'echarts/component/grid',
  85. 'echarts/component/tooltip',
  86. 'echarts/component/dataZoom'
  87. ], function (ec) {
  88. echarts = ec;
  89. chart = myChart = echarts.init(document.getElementById('main'), null, {
  90. renderer: 'canvas'
  91. });
  92. // -------------------------------------------------------------------
  93. // -------------------------------------------------------------------
  94. // -------------------------------------------------------------------
  95. option = {
  96. tooltip : {
  97. trigger: 'item'
  98. },
  99. toolbox: {
  100. show : true,
  101. feature : {
  102. mark : {show: true},
  103. dataView : {show: true, readOnly: false},
  104. magicType: {show: true, type: ['line', 'bar']},
  105. restore : {show: true},
  106. saveAsImage : {show: true}
  107. }
  108. },
  109. calculable : true,
  110. legend: {
  111. data:['Budget 2011', 'Budget 2012'],
  112. itemGap: 5
  113. },
  114. grid: {
  115. top: 500, // For touch test, make grid rect y more than 500.
  116. left: '1%',
  117. right: '10%',
  118. containLabel: true
  119. },
  120. xAxis: [
  121. {
  122. type : 'category',
  123. data : [1,2,3,4,5,6,7,8,9,10,11]
  124. }
  125. ],
  126. yAxis: [
  127. {
  128. type : 'value',
  129. name : 'Budget (million USD)',
  130. max: 300,
  131. axisLabel: {
  132. formatter: function (a) {
  133. return
  134. }
  135. }
  136. }
  137. ],
  138. dataZoom: [
  139. {
  140. show: true,
  141. start: 20,
  142. end: 70,
  143. handleSize: 8
  144. },
  145. {
  146. type: 'inside',
  147. start: 20,
  148. end: 70
  149. },
  150. ],
  151. series : [
  152. {
  153. name: 'Budget 2011',
  154. type: 'bar',
  155. data: [34,65,11,44,55,32,76,91,3,21,98]
  156. },
  157. {
  158. name: 'Budget 2012',
  159. type: 'bar',
  160. data: [24,35,51,94,35,9,23,56,11,45,64]
  161. }
  162. ]
  163. }
  164. // -------------------------------------------------------------------
  165. // -------------------------------------------------------------------
  166. // -------------------------------------------------------------------
  167. chart.setOption(option);
  168. });
  169. </script>
  170. </body>
  171. </html>