updateLayout(cfg)

    • 如果参数 中含有 type 字段,type 字段类型为 String,且与现有布局方法不同,则更换布局;
    • 如果参数 cfg 中不包含 type 字段,则保持原有布局,仅更新布局配置项。参数
    1. const graph = new G6.Graph({
    2. container: 'mountNode',
    3. width: 1000,
    4. height: 600,
    5. default: ['drag-canvas', 'drag-node'],
    6. },
    7. layout: {
    8. type: 'circular',
    9. center: [500, 300],
    10. },
    11. animate: true,
    12. });
    13. graph.render();
    14. // 实例化时通过layout指定布局,在合适的时候通过updateLayout更新布局配置
    15. graph.updateLayout({
    16. radius: 200,
    17. startAngle: Math.PI / 4,
    18. endAngle: Math.PI,
    19. divisions: 5,
    20. });