dynamicPieRadar.html 6.4 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. option = {
  36. title : {
  37. text: '动态数据',
  38. subtext: '纯属虚构'
  39. },
  40. tooltip : {
  41. trigger: 'item'
  42. },
  43. legend: {
  44. data:['随机数据1','随机数据2','随机数据3','随机数据4','随机数据5']
  45. },
  46. toolbox: {
  47. show : true,
  48. feature : {
  49. mark : {show: true},
  50. dataView : {show: true, readOnly: false},
  51. restore : {show: true},
  52. saveAsImage : {show: true}
  53. }
  54. },
  55. polar : [
  56. {
  57. indicator : [
  58. { text : '指标一' },
  59. { text : '指标二' },
  60. { text : '指标三' },
  61. { text : '指标四' },
  62. { text : '指标五' }
  63. ],
  64. center : [document.getElementById('main').offsetWidth - 250, 225],
  65. radius : 100
  66. }
  67. ],
  68. calculable : false,
  69. series : [
  70. {
  71. name:'pie',
  72. type:'pie',
  73. radius : [0, 110],
  74. center: [250, 225],
  75. data: (function (){
  76. var res = [];
  77. var len = 0;
  78. while (len++ < 5) {
  79. res.push({
  80. name: '随机数据' + len,
  81. value: Math.round(Math.random()*10)
  82. });
  83. }
  84. return res;
  85. })()
  86. },
  87. {
  88. name: 'radar',
  89. type: 'radar',
  90. itemStyle: {normal: {areaStyle: {type: 'default'}}},
  91. data: (function (){
  92. var res = [];
  93. var len = 0;
  94. while (len++ < 3) {
  95. res.push({
  96. name: 'data' + len,
  97. value: [
  98. Math.round(Math.random()*100),
  99. Math.round(Math.random()*100),
  100. Math.round(Math.random()*100),
  101. Math.round(Math.random()*100),
  102. Math.round(Math.random()*100)
  103. ]
  104. });
  105. }
  106. return res;
  107. })()
  108. }
  109. ]
  110. };
  111. var lastIndex = 5;
  112. var axisData;
  113. clearInterval(timeTicket);
  114. timeTicket = setInterval(function (){
  115. lastIndex += 1;
  116. // 动态数据接口 addData
  117. myChart.addData([
  118. [
  119. 0, // 系列索引
  120. { // 新增数据
  121. name: '随机数据' + lastIndex,
  122. value: Math.round(Math.random()*10)
  123. },
  124. false, // 新增数据是否从队列头部插入
  125. false, // 是否增加队列长度,false则自定删除原有数据,队头插入删队尾,队尾插入删队头
  126. '随机数据' + lastIndex
  127. ],
  128. [
  129. 1, // 系列索引
  130. { // 新增数据
  131. name: 'data' + lastIndex,
  132. value: [
  133. Math.round(Math.random()*100),
  134. Math.round(Math.random()*100),
  135. Math.round(Math.random()*100),
  136. Math.round(Math.random()*100),
  137. Math.round(Math.random()*100)
  138. ]
  139. },
  140. false, // 新增数据是否从队列头部插入
  141. false // 是否增加队列长度,false则自定删除原有数据,队头插入删队尾,队尾插入删队头
  142. ]
  143. ]);
  144. }, 2000);
  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 type="text/javascript">var timeTicket;</script>
  167. <script src="../asset/js/echartsExample.js"></script>
  168. </body>
  169. </html>