nodes-edges.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>内置的节点和边</title>
  6. </head>
  7. <body>
  8. <div id="mountNode"></div>
  9. <script src="../build/g6.js"></script>
  10. <script>
  11. const data = {
  12. nodes: [{
  13. x: 100,
  14. y: 100,
  15. shape: 'circle',
  16. label: 'circle',
  17. labelCfg: {
  18. position: 'bottom'
  19. }
  20. },{
  21. x: 200,
  22. y: 100,
  23. shape: 'rect',
  24. label: 'rect',
  25. labelCfg: {
  26. position: 'bottom'
  27. }
  28. },{
  29. x: 300,
  30. y: 100,
  31. size: [60, 30],
  32. shape: 'ellipse',
  33. label: 'ellipse',
  34. labelCfg: {
  35. position: 'bottom'
  36. }
  37. },{
  38. x: 400,
  39. y: 100,
  40. shape: 'image',
  41. img: 'https://gw.alipayobjects.com/zos/rmsportal/XuVpGqBFxXplzvLjJBZB.svg',
  42. label: 'image',
  43. labelCfg: {
  44. position: 'bottom'
  45. }
  46. }
  47. ],
  48. edges: [
  49. {
  50. source: {x: 100, y: 200},
  51. target: {x: 200, y: 200},
  52. label: 'line',
  53. labelCfg: {
  54. refY: 10
  55. }
  56. },
  57. {
  58. source: {x: 250, y: 200},
  59. target: {x: 360, y: 200},
  60. controlPoints: [{x: 300, y: 220}],
  61. shape: 'polyline',
  62. label: 'polyline',
  63. labelCfg: {
  64. refY: 10,
  65. refX: 0
  66. }
  67. },
  68. {
  69. source: {x: 100, y: 300},
  70. target: {x: 200, y: 300},
  71. shape: 'quadratic',
  72. label: 'quadratic',
  73. labelCfg: {
  74. refY: 10,
  75. refX: 0
  76. }
  77. },{
  78. source: {x: 250, y: 300},
  79. target: {x: 360, y: 300},
  80. shape: 'cubic',
  81. label: 'cubic',
  82. labelCfg: {
  83. refY: 10,
  84. refX: 0
  85. }
  86. }
  87. ]};
  88. const graph = new G6.Graph({
  89. container: 'mountNode',
  90. width: 1000,
  91. height: 600
  92. });
  93. graph.data(data);
  94. graph.render();
  95. </script>
  96. </body>
  97. </html>