tooltip.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 : { // Option config. Can be overwrited by series or data
  37. trigger: 'axis',
  38. //show: true, //default true
  39. showDelay: 0,
  40. hideDelay: 50,
  41. transitionDuration:0,
  42. backgroundColor : 'rgba(255,0,255,0.7)',
  43. borderColor : '#f50',
  44. borderRadius : 8,
  45. borderWidth: 2,
  46. padding: 10, // [5, 10, 15, 20]
  47. position : function(p) {
  48. // 位置回调
  49. // console.log && console.log(p);
  50. return [p[0] + 10, p[1] - 10];
  51. },
  52. textStyle : {
  53. color: 'yellow',
  54. decoration: 'none',
  55. fontFamily: 'Verdana, sans-serif',
  56. fontSize: 15,
  57. fontStyle: 'italic',
  58. fontWeight: 'bold'
  59. },
  60. formatter: function (params,ticket,callback) {
  61. console.log(params)
  62. var res = 'Function formatter : <br/>' + params[0].name;
  63. for (var i = 0, l = params.length; i < l; i++) {
  64. res += '<br/>' + params[i].seriesName + ' : ' + params[i].value;
  65. }
  66. setTimeout(function (){
  67. // 仅为了模拟异步回调
  68. callback(ticket, res);
  69. }, 1000)
  70. return 'loading';
  71. }
  72. //formatter: "Template formatter: <br/>{b}<br/>{a}:{c}<br/>{a1}:{c1}"
  73. },
  74. toolbox: {
  75. show : true,
  76. feature : {
  77. mark : {show: true},
  78. dataView : {show: true, readOnly: false},
  79. magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},
  80. restore : {show: true},
  81. saveAsImage : {show: true}
  82. }
  83. },
  84. calculable : true,
  85. xAxis : {
  86. data : ['周一','周二','周三','周四','周五','周六','周日']
  87. },
  88. yAxis : {
  89. type : 'value'
  90. },
  91. series : [
  92. {
  93. name:'坐标轴触发1',
  94. type:'bar',
  95. data:[
  96. {value:320, extra:'Hello~'},
  97. 332, 301, 334, 390, 330, 320
  98. ]
  99. },
  100. {
  101. name:'坐标轴触发2',
  102. type:'bar',
  103. data:[862, 1018, 964, 1026, 1679, 1600, 157]
  104. },
  105. {
  106. name:'数据项触发1',
  107. type:'bar',
  108. tooltip : { // Series config.
  109. trigger: 'item',
  110. backgroundColor: 'black',
  111. position : [0, 0],
  112. formatter: "Series formatter: <br/>{a}<br/>{b}:{c}"
  113. },
  114. stack: '数据项',
  115. data:[
  116. 120, 132,
  117. {
  118. value: 301,
  119. itemStyle: {normal: {color: 'red'}},
  120. tooltip : { // Data config.
  121. backgroundColor: 'blue',
  122. formatter: "Data formatter: <br/>{a}<br/>{b}:{c}"
  123. }
  124. },
  125. 134, 90,
  126. {
  127. value: 230,
  128. tooltip: {show: false}
  129. },
  130. 210
  131. ]
  132. },
  133. {
  134. name:'数据项触发2',
  135. type:'bar',
  136. tooltip : {
  137. show : false,
  138. trigger: 'item'
  139. },
  140. stack: '数据项',
  141. data:[150, 232, 201, 154, 190, 330, 410]
  142. }
  143. ]
  144. };
  145. </textarea>
  146. </div><!--/.well -->
  147. </div><!--/span-->
  148. <div id="graphic" class="col-md-8">
  149. <div id="main" class="main"></div>
  150. <div>
  151. <button type="button" class="btn btn-sm btn-success" onclick="refresh(true)">刷 新</button>
  152. <span class="text-primary">切换主题</span>
  153. <select id="theme-select"></select>
  154. <span id='wrong-message' style="color:red"></span>
  155. </div>
  156. </div><!--/span-->
  157. </div><!--/row-->
  158. </div><!--/.fluid-container-->
  159. <footer id="footer"></footer>
  160. <!-- Le javascript
  161. ================================================== -->
  162. <!-- Placed at the end of the document so the pages load faster -->
  163. <script src="../asset/js/jquery.min.js"></script>
  164. <script type="text/javascript" src="../asset/js/echartsHome.js"></script>
  165. <script src="../asset/js/bootstrap.min.js"></script>
  166. <script src="../asset/js/echartsExample.js"></script>
  167. </body>
  168. </html>