graph-simple.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <script src="esl.js"></script>
  5. <script src="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. layout: 'none',
  36. symbolSize: 50,
  37. roam: true,
  38. label: {
  39. normal: {
  40. show: true
  41. }
  42. },
  43. edgeSymbol: ['circle', 'arrow'],
  44. edgeSymbolSize: [4, 10],
  45. edgeLabel: {
  46. normal: {
  47. textStyle: {
  48. fontSize: 20
  49. }
  50. }
  51. },
  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. }
  78. },
  79. lineStyle: {
  80. normal: {
  81. width: 5,
  82. curveness: 0.2
  83. }
  84. }
  85. }, {
  86. source: '节点2',
  87. target: '节点1',
  88. label: {
  89. normal: {
  90. show: true
  91. }
  92. },
  93. lineStyle: {
  94. normal: { curveness: 0.2 }
  95. }
  96. }, {
  97. source: '节点1',
  98. target: '节点3'
  99. }, {
  100. source: '节点2',
  101. target: '节点3'
  102. }, {
  103. source: '节点2',
  104. target: '节点4'
  105. }, {
  106. source: '节点1',
  107. target: '节点4'
  108. }],
  109. lineStyle: {
  110. normal: {
  111. curveness: 0
  112. }
  113. }
  114. }
  115. ]
  116. };
  117. chart.setOption(option);
  118. });
  119. </script>
  120. </body>
  121. </html>