graph-simple.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="lib/esl.js"></script>
  5. <script src="lib/config.js"></script>
  6. <script src="lib/jquery.min.js"></script>
  7. </head>
  8. <body>
  9. <style>
  10. html, body, #main {
  11. width: 100%;
  12. height: 100%;
  13. margin: 0;
  14. }
  15. </style>
  16. <div id="main"></div>
  17. <script>
  18. require([
  19. 'echarts',
  20. // 'echarts/chart/graph',
  21. // 'echarts/component/title',
  22. // 'echarts/component/legend',
  23. // 'echarts/component/tooltip',
  24. // 'zrender/vml/vml',
  25. 'theme/vintage'
  26. ], function (echarts) {
  27. var chart = echarts.init(document.getElementById('main'), 'vintage');
  28. var option = {
  29. tooltip: {},
  30. animationDurationUpdate: 1500,
  31. animationEasingUpdate: 'quinticInOut',
  32. series : [
  33. {
  34. type: 'graph',
  35. symbolSize: 50,
  36. roam: true,
  37. label: {
  38. normal: {
  39. show: true
  40. }
  41. },
  42. edgeSymbol: ['circle', 'arrow'],
  43. edgeSymbolSize: [4, 10],
  44. edgeLabel: {
  45. normal: {
  46. textStyle: {
  47. fontSize: 20
  48. }
  49. }
  50. },
  51. focusNodeAdjacency: true,
  52. data: [{
  53. name: '节点1',
  54. x: 300,
  55. y: 300
  56. }, {
  57. name: '节点2',
  58. x: 800,
  59. y: 300
  60. }, {
  61. name: '节点3',
  62. x: 550,
  63. y: 100
  64. }, {
  65. name: '节点4',
  66. x: 550,
  67. y: 500
  68. }],
  69. // links: [],
  70. links: [{
  71. source: 0,
  72. target: 1,
  73. symbolSize: [5, 20],
  74. label: {
  75. normal: {
  76. show: true
  77. // position: 'end'
  78. }
  79. },
  80. lineStyle: {
  81. normal: {
  82. width: 5,
  83. curveness: 0.2
  84. }
  85. }
  86. }, {
  87. source: '节点2',
  88. target: '节点1',
  89. label: {
  90. normal: {
  91. show: true
  92. }
  93. },
  94. lineStyle: {
  95. normal: { curveness: 0.2 }
  96. }
  97. }, {
  98. source: '节点1',
  99. target: '节点3'
  100. }, {
  101. source: '节点2',
  102. target: '节点3'
  103. }, {
  104. source: '节点2',
  105. target: '节点4'
  106. }, {
  107. source: '节点1',
  108. target: '节点4'
  109. }],
  110. lineStyle: {
  111. normal: {
  112. curveness: 0
  113. }
  114. }
  115. }
  116. ]
  117. };
  118. chart.setOption(option);
  119. });
  120. </script>
  121. </body>
  122. </html>