5f1926bef3c98f4b372056bb1ff66c41a3319640.svn-base 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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="javascript:;" onclick="autoResize()" class="glyphicon glyphicon-resize-full" id ="icon-resize" ></a>option</div>
  34. <textarea id="code" name="code">
  35. var nodes = [];
  36. var links = [];
  37. var constMaxDepth = 4;
  38. var constMaxChildren = 3;
  39. var constMinChildren = 2;
  40. var constMaxRadius = 10;
  41. var constMinRadius = 2;
  42. var mainDom = document.getElementById('main');
  43. function rangeRandom(min, max) {
  44. return Math.random() * (max - min) + min;
  45. }
  46. function createRandomNode(depth) {
  47. var x = mainDom.clientWidth / 2 + (.5 - Math.random()) * 200;
  48. var y = (mainDom.clientHeight - 20) * depth / (constMaxDepth + 1) + 20;
  49. var node = {
  50. name : 'NODE_' + nodes.length,
  51. value : rangeRandom(constMinRadius, constMaxRadius),
  52. // Custom properties
  53. id : nodes.length,
  54. depth : depth,
  55. initial : [x, y],
  56. fixY : true,
  57. category : depth === constMaxDepth ? 0 : 1
  58. }
  59. nodes.push(node);
  60. return node;
  61. }
  62. function forceMockThreeData() {
  63. var depth = 0;
  64. var rootNode = createRandomNode(0);
  65. rootNode.name = 'ROOT';
  66. rootNode.category = 2;
  67. function mock(parentNode, depth) {
  68. var nChildren = Math.round(rangeRandom(constMinChildren, constMaxChildren));
  69. for (var i = 0; i < nChildren; i++) {
  70. var childNode = createRandomNode(depth);
  71. links.push({
  72. source : parentNode.id,
  73. target : childNode.id,
  74. weight : 1
  75. });
  76. if (depth < constMaxDepth) {
  77. mock(childNode, depth + 1);
  78. }
  79. }
  80. }
  81. mock(rootNode, 1);
  82. }
  83. forceMockThreeData();
  84. option = {
  85. title : {
  86. text: 'Force',
  87. subtext: 'Force-directed tree',
  88. x:'right',
  89. y:'bottom'
  90. },
  91. tooltip : {
  92. trigger: 'item',
  93. formatter: '{a} : {b}'
  94. },
  95. toolbox: {
  96. show : true,
  97. feature : {
  98. restore : {show: true},
  99. magicType: {show: true, type: ['force', 'chord']},
  100. saveAsImage : {show: true}
  101. }
  102. },
  103. legend: {
  104. x: 'left',
  105. data:['叶子节点','非叶子节点', '根节点']
  106. },
  107. series : [
  108. {
  109. type:'force',
  110. name : "Force tree",
  111. ribbonType: false,
  112. categories : [
  113. {
  114. name: '叶子节点',
  115. itemStyle: {
  116. normal: {
  117. color : '#ff7f50'
  118. }
  119. }
  120. },
  121. {
  122. name: '非叶子节点',
  123. itemStyle: {
  124. normal: {
  125. color : '#6f57bc'
  126. }
  127. }
  128. },
  129. {
  130. name: '根节点',
  131. itemStyle: {
  132. normal: {
  133. color : '#af0000'
  134. }
  135. }
  136. }
  137. ],
  138. itemStyle: {
  139. normal: {
  140. label: {
  141. show: false
  142. },
  143. nodeStyle : {
  144. brushType : 'both',
  145. strokeColor : 'rgba(255,215,0,0.6)',
  146. lineWidth : 1
  147. }
  148. }
  149. },
  150. minRadius : constMinRadius,
  151. maxRadius : constMaxRadius,
  152. nodes : nodes,
  153. links : links
  154. }
  155. ]
  156. };
  157. </textarea>
  158. </div><!--/.well -->
  159. </div><!--/span-->
  160. <div id="graphic" class="col-md-8">
  161. <div id="main" class="main"></div>
  162. <div>
  163. <button type="button" class="btn btn-sm btn-success" onclick="refresh(true)">刷 新</button>
  164. <span class="text-primary">切换主题</span>
  165. <select id="theme-select"></select>
  166. <span id='wrong-message' style="color:red"></span>
  167. </div>
  168. </div><!--/span-->
  169. </div><!--/row-->
  170. </div><!--/.fluid-container-->
  171. <footer id="footer"></footer>
  172. <!-- Le javascript
  173. ================================================== -->
  174. <!-- Placed at the end of the document so the pages load faster -->
  175. <script src="../asset/js/jquery.min.js"></script>
  176. <script type="text/javascript" src="../asset/js/echartsHome.js"></script>
  177. <script src="../asset/js/bootstrap.min.js"></script>
  178. <script src="../asset/js/echartsExample.js"></script>
  179. </body>
  180. </html>