pluginMinimap.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7. <title>插件-缩略图</title>
  8. </head>
  9. <body>
  10. <div style="position: relative;">
  11. <div id="mountNode"></div>
  12. <div id="minimap" style="border: 1px solid #999; position: absolute; top: 0px;"></div>
  13. </div>
  14. <script src="../build/g6.js"></script>
  15. <script src="../build/toolMinimap.js"></script>
  16. <script>
  17. const Plugin = window.ToolMinimap;
  18. const plugin = new Plugin({
  19. container: 'minimap',
  20. width: 180,
  21. height: 120
  22. });
  23. const data = {
  24. nodes: [{
  25. id: 'node0',
  26. x: -100,
  27. y: 200
  28. }, {
  29. id: 'node1',
  30. x: 100,
  31. y: 200
  32. }, {
  33. id: 'node2',
  34. x: 300,
  35. y: 200
  36. }, {
  37. id: 'node3',
  38. x: 600,
  39. y: 200
  40. }],
  41. edges: [{
  42. target: 'node0',
  43. source: 'node1'
  44. }, {
  45. target: 'node2',
  46. source: 'node1'
  47. }, {
  48. target: 'node2',
  49. source: 'node3'
  50. }]
  51. };
  52. const graph = new G6.Graph({
  53. container: 'mountNode',
  54. fitView: 'cc',
  55. height: window.innerHeight,
  56. plugins: [plugin]
  57. });
  58. graph.read(data);
  59. </script>
  60. </body>
  61. </html>