question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to draw an edge from a child to parent compound graph

See original GitHub issue

Hi all,

I am currently using Dagre for one of my data visualisation project, it is a compound graph which requires a node to contain a nested node, I’m unable to draw edges from child nodes to parent nodes, I get the following error:

Uncaught TypeError: Cannot set property ‘rank’ of undefined.

Please also see the below code:

g.setNode('a', {label: 'A'}); g.setNode('b', {label: 'B'}); g.setNode('c', {label: 'C'}); g.setNode('d', {label: 'D'});

g.setNode('top_group', {label: 'Top Group', clusterLabelPos: 'bottom', style: 'fill: #ffd47f'}); g.setNode('bottom_group', {label: 'Group', clusterLabelPos: 'top', style: 'fill: #d3d7e8'});

// Set the parents to define which nodes belong to which cluster g.setParent('a', 'top_group'); g.setParent('b', 'bottom_group'); g.setParent('c', 'bottom_group'); g.setParent('d', 'bottom_group');

// Draw edges g.setEdge('a', 'b'); g.setEdge('b', 'c'); g.setEdge('b', 'd');

// Set edge from child to parent g.setEdge('a', 'bottom_group'); // THIS LINE CAUSES THE ABOVE ERROR

The way how we create a parent is the same as how we create a child node, so the library should allow us to draw an edge from a child node to a parent node.

Can someone please advice?

This is really urgent so can someone please help.

Much appreciated, Thanks, Michael

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:12

github_iconTop GitHub Comments

0reactions
420407904commented, Apr 19, 2022
if (isNode(element)) {
      const { data,id } = element
      if(id!=="0"){
        const {parentId} = data
        if(parentId===0||parentId){
          g.setParent(id, parentId+"");
        }
      }
      g.setNode(element.id, {
        width: element.__rf?.width,
        height: element.__rf?.height,
      });
    } else {
      g.setEdge(element.source, element.target);
    }

I used setEdge before but i got the graph drawn by the nodes of the second level is evenly spaced, so I think they are caused by no parent-child relationship So you see that code i added the setParent I hope they can divide the space equally in their own area but i failed Uncaught TypeError: Cannot set properties of undefined (setting 'rank') i don’t know what to use

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can we choose another edge form for loop edge type or child ...
I'm trying to draw edge from node to its parent. I'm expecting to have straight line from the node to the outer frame...
Read more >
Attributes - Graphviz
Instructions to customise the layout of Graphviz nodes, edges, graphs, subgraphs, and clusters. The table below describes the attributes used by ...
Read more >
Arrows from child to parent in a tree - LaTeX Stack Exchange
Use edge from parent/.style={draw, dashed, <-} to get a dashed arrow. \documentclass[tikz, border=1cm]{standalone ...
Read more >
PRACTICAL GREMLIN: An Apache TinkerPop Tutorial
Vertices represent "things" such as people or places. Edges represent connections between those vertices, and properties are information added ...
Read more >
3 Adding Views for Display in Dashboards - Oracle Help Center
The view is displayed in a container on the "Compound Layout. ... markers in child graphs may be extremely small and hard to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found