dagrejs / dagre-d3

A D3-based renderer for Dagre
MIT License
2.86k stars 592 forks source link

zero size vertices in dag #163

Open kamalhakim opened 9 years ago

kamalhakim commented 9 years ago

The rect and foreignobject being generated for each node in my DAG have both "width" and "height" equal to 0 . Label's of nodes are html as following:

          var nodeHtml = '<div>';
          nodeHtml += '<span class="status"></span>';
          nodeHtml += '<span class="name">' + task.name + '</span>';
          nodeHtml += '<span class="queue">' + task.machine + '</span>';
          nodeHtml += '</div>';

If I set width and height values on node like below, it just applies it to "g" tag while "rect" and "foreignobject" remain with zero values.

          nodes.push({
            id: task.id,
            value: {
              label: nodeHtml,
              width: 200,
              height: 40
            }
          });

The other workaround was to search and change them after rendering but it still doesn't change it for "foreignobject" and more importantly this way the size of the nodes are not taken into account in the placement algorithm for avoiding overlaps.

var oldDrawNodes = dagreRenderer.drawNodes();
        dagreRenderer.drawNodes(function(graph, root) {
          var svgNodes = oldDrawNodes(graph, root);
          svgNodes.selectAll("rect")
            .attr("width", 200)
            .attr("height", 40)
           return svgNodes;
        });

Note: Earlier I was using this code inside a JSF project and it worked like a charm, now I moved everything into Angularjs project that this issue has happened.

I am really confused, I don't know whether it is because of angular d3 combination or whether I miss something in my code or it is a dagre issue!!

itscharu commented 8 years ago

Hi,

Were you able to figure out the issue.

I am facing the same issue.

Thanks, Charu

kamalhakim commented 8 years ago

Not really, I just realized when my DAG data is changed, shortly after the creating it for the first time, dagre redraws it correctly and the DAG becomes expanded. I still don't have any explanation for this behaviour I hope someone from dagre can help us.