How to use the graphlib/lib/graph function in graphlib

To help you get started, we’ve selected a few graphlib 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 aclowes / yawn / frontend / src / WorkflowDetailGraph.js View on Github external
componentDidMount() {
    /* After rendering, draw the graph */
    const workflow = this.props.workflow;
    const renderer = new dagreD3.render();
    const graph = new Graph().setGraph({});

    workflow.tasks.forEach(function (task) {
      // Add nodes: rx ry is border radius
      graph.setNode(task.name, {label: task.name, rx: 5, ry: 5});

      // Add lines between nodes
      task.upstream.forEach(function (upstreamTask) {
        graph.setEdge(upstreamTask, task.name, {})
      })
    });

    const svg = d3.select("svg");
    const g = svg.append("g");
    renderer(g, graph);
    svg.attr('height', graph.graph().height);
    svg.attr('width', graph.graph().width);