graphAnimate.html 900 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 id="mountNode"></div>
  11. <script src="../build/g6.js"></script>
  12. <script>
  13. const data = {
  14. nodes: [{
  15. id: 'node1',
  16. x: 100,
  17. y: 200
  18. }],
  19. };
  20. const graph = new G6.Graph({
  21. container: 'mountNode',
  22. fitView: 'cc',
  23. height: window.innerHeight,
  24. animate: true
  25. });
  26. graph.read(data);
  27. setTimeout(() => {
  28. graph.update('node1', {
  29. x: 50,
  30. y: 50
  31. });
  32. }, 1000);
  33. setTimeout(() => {
  34. graph.update('node1', {
  35. x: 200,
  36. y: 50
  37. });
  38. }, 1200);
  39. setTimeout(() => {
  40. graph.remove('node1');
  41. }, 2000);
  42. </script>
  43. </body>
  44. </html>