event.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <meta name="description" content="ECharts">
  8. <meta name="author" content="kener.linfeng@gmail.com">
  9. <title>ECharts · Example</title>
  10. <link rel="shortcut icon" href="../asset/ico/favicon.png">
  11. <link href="../asset/css/font-awesome.min.css" rel="stylesheet">
  12. <link href="../asset/css/bootstrap.css" rel="stylesheet">
  13. <link href="../asset/css/carousel.css" rel="stylesheet">
  14. <link href="../asset/css/echartsHome.css" rel="stylesheet">
  15. <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
  16. <!--[if lt IE 9]>
  17. <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
  18. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  19. <![endif]-->
  20. <script src="./www/js/echarts.js"></script>
  21. <script src="../asset/js/codemirror.js"></script>
  22. <script src="../asset/js/javascript.js"></script>
  23. <link href="../asset/css/codemirror.css" rel="stylesheet">
  24. <link href="../asset/css/monokai.css" rel="stylesheet">
  25. </head>
  26. <body>
  27. <!-- Fixed navbar -->
  28. <div class="navbar navbar-default navbar-fixed-top" role="navigation" id="head"></div>
  29. <div class="container-fluid">
  30. <div class="row-fluid example">
  31. <div id="sidebar-code" class="col-md-4">
  32. <div class="well sidebar-nav">
  33. <div class="nav-header"><a href="#" onclick="autoResize()" class="glyphicon glyphicon-resize-full" id ="icon-resize" ></a>option</div>
  34. <textarea id="code" name="code">
  35. option = {
  36. tooltip : {
  37. trigger: 'axis'
  38. },
  39. legend: {
  40. data:['最高','最低']
  41. },
  42. toolbox: {
  43. show : true,
  44. feature : {
  45. mark : {show: true},
  46. dataView : {readOnly:false},
  47. magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
  48. restore : {show: true},
  49. saveAsImage : {show: true}
  50. }
  51. },
  52. calculable : true,
  53. dataZoom : {
  54. show : true,
  55. realtime : true,
  56. start : 40,
  57. end : 60
  58. },
  59. xAxis : [
  60. {
  61. type : 'category',
  62. boundaryGap : true,
  63. data : function (){
  64. var list = [];
  65. for (var i = 1; i <= 30; i++) {
  66. list.push('2013-03-' + i);
  67. }
  68. return list;
  69. }()
  70. }
  71. ],
  72. yAxis : [
  73. {
  74. type : 'value'
  75. }
  76. ],
  77. series : [
  78. {
  79. name:'最高',
  80. type:'line',
  81. data:function (){
  82. var list = [];
  83. for (var i = 1; i <= 30; i++) {
  84. list.push(Math.round(Math.random()* 30) + 30);
  85. }
  86. return list;
  87. }()
  88. },
  89. {
  90. name:'最低',
  91. type:'bar',
  92. data:function (){
  93. var list = [];
  94. for (var i = 1; i <= 30; i++) {
  95. list.push(Math.round(Math.random()* 10));
  96. }
  97. return list;
  98. }()
  99. }
  100. ]
  101. };
  102. var ecConfig = require('echarts/config');
  103. function eConsole(param) {
  104. var mes = '【' + param.type + '】';
  105. if (typeof param.seriesIndex != 'undefined') {
  106. mes += ' seriesIndex : ' + param.seriesIndex;
  107. mes += ' dataIndex : ' + param.dataIndex;
  108. }
  109. if (param.type == 'hover') {
  110. document.getElementById('hover-console').innerHTML = 'Event Console : ' + mes;
  111. }
  112. else {
  113. document.getElementById('console').innerHTML = mes;
  114. }
  115. console.log(param);
  116. }
  117. /*
  118. // -------全局通用
  119. REFRESH: 'refresh',
  120. RESTORE: 'restore',
  121. RESIZE: 'resize',
  122. CLICK: 'click',
  123. DBLCLICK: 'dblclick',
  124. HOVER: 'hover',
  125. MOUSEOUT: 'mouseout',
  126. // -------业务交互逻辑
  127. DATA_CHANGED: 'dataChanged',
  128. DATA_ZOOM: 'dataZoom',
  129. DATA_RANGE: 'dataRange',
  130. DATA_RANGE_HOVERLINK: 'dataRangeHoverLink',
  131. LEGEND_SELECTED: 'legendSelected',
  132. LEGEND_HOVERLINK: 'legendHoverLink',
  133. MAP_SELECTED: 'mapSelected',
  134. PIE_SELECTED: 'pieSelected',
  135. MAGIC_TYPE_CHANGED: 'magicTypeChanged',
  136. DATA_VIEW_CHANGED: 'dataViewChanged',
  137. TIMELINE_CHANGED: 'timelineChanged',
  138. MAP_ROAM: 'mapRoam',
  139. */
  140. myChart.on(ecConfig.EVENT.CLICK, eConsole);
  141. myChart.on(ecConfig.EVENT.DBLCLICK, eConsole);
  142. //myChart.on(ecConfig.EVENT.HOVER, eConsole);
  143. myChart.on(ecConfig.EVENT.DATA_ZOOM, eConsole);
  144. myChart.on(ecConfig.EVENT.LEGEND_SELECTED, eConsole);
  145. myChart.on(ecConfig.EVENT.MAGIC_TYPE_CHANGED, eConsole);
  146. myChart.on(ecConfig.EVENT.DATA_VIEW_CHANGED, eConsole);
  147. </textarea>
  148. </div><!--/.well -->
  149. </div><!--/span-->
  150. <div id="graphic" class="col-md-8">
  151. <div id="main" class="main"></div>
  152. <div>
  153. <button type="button" class="btn btn-sm btn-success" onclick="refresh(true)">刷 新</button>
  154. <span class="text-primary">切换主题</span>
  155. <select id="theme-select"></select>
  156. <span id='wrong-message' style="color:red"></span>
  157. <span id='hover-console' style="color:#1e90ff"></span>
  158. <span id='console' style="color:#1e90ff">Event Console</span>
  159. </div>
  160. </div><!--/span-->
  161. </div><!--/row-->
  162. </div><!--/.fluid-container-->
  163. <footer id="footer"></footer>
  164. <!-- Le javascript
  165. ================================================== -->
  166. <!-- Placed at the end of the document so the pages load faster -->
  167. <script src="../asset/js/jquery.min.js"></script>
  168. <script type="text/javascript" src="../asset/js/echartsHome.js"></script>
  169. <script src="../asset/js/bootstrap.min.js"></script>
  170. <script src="../asset/js/echartsExample.js"></script>
  171. </body>
  172. </html>