How to use the @antv/g6.Layout function in @antv/g6

To help you get started, we’ve selected a few @antv/g6 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antvis / Graphin / packages / graphin / src / layout / g6 / dagre.ts View on Github external
const dagreLayout = (data: Data, options: DagreLayoutOption): Data => {
    const source = cloneDeep(data);
    // eslint-disable-next-line new-cap
    const layout = new G6.Layout.dagre({
        type: 'dagre',
        ...options,
    });

    layout.init(source);
    layout.execute();
    return {
        nodes: layout.nodes,
        edges: data.edges,
    };

    // graph.positionsAnimate();
};
export default dagreLayout;
github antvis / G6 / examples / net / layoutMechanism / demo / subgraphLayout.js View on Github external
nodes.forEach(function(node, i) {
    if (i <= 16 && i !== 12) {
      newNodes.push(node);
      newNodeMap.set(node.id, i);
    }
  });
  // add related edges
  edges.forEach(function(edge) {
    const sourceId = edge.source;
    const targetId = edge.target;
    if (newNodeMap.get(sourceId) !== undefined && newNodeMap.get(targetId) !== undefined) {
      newEdges.push(edge);
    }
  });

  const subForceLayout = new G6.Layout.force({
    center: [ nodes[0].x, nodes[0].y ],
    linkDistance: 70,
    preventOverlap: true,
    nodeSize: 20,
    tick: function tick() {
      // the tick function to show the animation of layout process
      graph.refreshPositions();
    }
  });
  subForceLayout.init({
    nodes: newNodes,
    edges: newEdges
  });
  subForceLayout.execute();
}, 1000);
github antvis / Graphin / packages / graphin / src / layout / g6 / radial.ts View on Github external
const radialLayout = (data: Data, options: RadialLayoutOption) => {
    const source = cloneDeep(data);
    // eslint-disable-next-line new-cap
    const layout = new G6.Layout.radial({
        ...options,
    });

    layout.init(source);
    layout.execute();

    return {
        nodes: layout.nodes,
        edges: data.edges,
    };
};
export default radialLayout;