mix7.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. // 虚拟构造同横纵坐标的两组数据
  36. var sData1 = (function () {
  37. var d = [];
  38. var len = 40;
  39. var value;
  40. while (len--) {
  41. d.push([
  42. Math.round(Math.random()*10) * (Math.round(Math.random()*10) > 5 ? 1 : -1),
  43. Math.round(Math.random()*10) * (Math.round(Math.random()*10) > 5 ? 1 : -1),
  44. Math.round(Math.random()*20)
  45. ]);
  46. }
  47. return d;
  48. })();
  49. var sData2 = (function () {
  50. var d = [];
  51. var len = sData1.length;
  52. for (var i = 0; i < len; i++) {
  53. d.push([
  54. sData1[i][0],
  55. sData1[i][1],
  56. Math.round(Math.random()*15)
  57. ]);
  58. }
  59. return d;
  60. })();
  61. option = {
  62. color : ['rgba(255, 69, 0, 0.5)', 'rgba(30, 144, 255, 0.5)'],
  63. title : {
  64. text: '饼图代替散点',
  65. subtext : '混搭'
  66. },
  67. tooltip : {
  68. trigger: 'item',
  69. formatter: "{b} : {c} ({d}%)"
  70. },
  71. toolbox: {
  72. show : true,
  73. feature : {
  74. mark : {show: true},
  75. dataView : {show: true, readOnly: false},
  76. restore : {show: true},
  77. saveAsImage : {show: true}
  78. }
  79. },
  80. xAxis : [
  81. {
  82. type : 'value',
  83. splitNumber: 2
  84. }
  85. ],
  86. yAxis : [
  87. {
  88. type : 'value',
  89. splitNumber: 2
  90. }
  91. ],
  92. animation: false,
  93. series : [
  94. {
  95. type:'scatter',
  96. symbol: 'none',
  97. data: sData1
  98. },
  99. {
  100. type:'scatter',
  101. symbol: 'none',
  102. data: sData2
  103. }
  104. ]
  105. };
  106. function buildPieSeries(){
  107. var xAxis = myChart.component.xAxis.getAxis(0);
  108. var yAxis = myChart.component.yAxis.getAxis(0);
  109. var len = sData1.length;
  110. option.series = option.series.slice(0,2);
  111. option.legend = {
  112. data : ['系列1', '系列2']
  113. };
  114. while (len--) {
  115. option.series.push({
  116. type: 'pie',
  117. itemStyle : {
  118. normal : {
  119. label : {
  120. show : false
  121. },
  122. labelLine : {
  123. show : false
  124. }
  125. }
  126. },
  127. radius : sData1[len][2] + sData2[len][2],
  128. center: [
  129. xAxis.getCoord(sData1[len][0]),
  130. yAxis.getCoord(sData1[len][1])
  131. ],
  132. data: [
  133. {name: '系列1', value: sData1[len][2]},
  134. {name: '系列2', value: sData2[len][2]}
  135. ]
  136. })
  137. }
  138. option.animation = true;
  139. myChart.setOption(option, true);
  140. window.onresize = buildPieSeries;
  141. }
  142. // 构造出一系列的饼图代替原来的散点,需要在散点画出来后才能获取到散点的坐标,setTimeout!
  143. setTimeout(buildPieSeries, 100);
  144. </textarea>
  145. </div><!--/.well -->
  146. </div><!--/span-->
  147. <div id="graphic" class="col-md-8">
  148. <div id="main" class="main"></div>
  149. <div>
  150. <button type="button" class="btn btn-sm btn-success" onclick="refresh(true)">刷 新</button>
  151. <span class="text-primary">切换主题</span>
  152. <select id="theme-select"></select>
  153. <span id='wrong-message' style="color:red"></span>
  154. </div>
  155. </div><!--/span-->
  156. </div><!--/row-->
  157. </div><!--/.fluid-container-->
  158. <footer id="footer"></footer>
  159. <!-- Le javascript
  160. ================================================== -->
  161. <!-- Placed at the end of the document so the pages load faster -->
  162. <script src="../asset/js/jquery.min.js"></script>
  163. <script type="text/javascript" src="../asset/js/echartsHome.js"></script>
  164. <script src="../asset/js/bootstrap.min.js"></script>
  165. <script src="../asset/js/echartsExample.js"></script>
  166. </body>
  167. </html>