touch-test.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <!DOCTYPE>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <script src="lib/esl.js"></script>
  6. <script src="lib/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="lib/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. });
  91. // -------------------------------------------------------------------
  92. // -------------------------------------------------------------------
  93. // -------------------------------------------------------------------
  94. option = {
  95. tooltip : {
  96. trigger: 'item'
  97. },
  98. toolbox: {
  99. show : true,
  100. feature : {
  101. mark : {show: true},
  102. dataView : {show: true, readOnly: false},
  103. magicType: {show: true, type: ['line', 'bar']},
  104. restore : {show: true},
  105. saveAsImage : {show: true}
  106. }
  107. },
  108. calculable : true,
  109. legend: {
  110. data:['Budget 2011', 'Budget 2012'],
  111. itemGap: 5
  112. },
  113. grid: {
  114. top: 500, // For touch test, make grid rect y more than 500.
  115. left: '1%',
  116. right: '10%',
  117. containLabel: true
  118. },
  119. xAxis: [
  120. {
  121. type : 'category',
  122. data : [1,2,3,4,5,6,7,8,9,10,11]
  123. }
  124. ],
  125. yAxis: [
  126. {
  127. type : 'value',
  128. name : 'Budget (million USD)',
  129. max: 300,
  130. axisLabel: {
  131. formatter: function (a) {
  132. return
  133. }
  134. }
  135. }
  136. ],
  137. dataZoom: [
  138. {
  139. show: true,
  140. start: 20,
  141. end: 70,
  142. handleSize: 8
  143. },
  144. {
  145. type: 'inside',
  146. start: 20,
  147. end: 70
  148. },
  149. ],
  150. series : [
  151. {
  152. name: 'Budget 2011',
  153. type: 'bar',
  154. data: [34,65,11,44,55,32,76,91,3,21,98]
  155. },
  156. {
  157. name: 'Budget 2012',
  158. type: 'bar',
  159. data: [24,35,51,94,35,9,23,56,11,45,64]
  160. }
  161. ]
  162. }
  163. // -------------------------------------------------------------------
  164. // -------------------------------------------------------------------
  165. // -------------------------------------------------------------------
  166. chart.setOption(option);
  167. });
  168. </script>
  169. </body>
  170. </html>