Avoid overlapping of nodes in tree layout in d3.js

Viewed 7310

I have created a collapsible tree to represent some biological data.

In this tree the size of the node represents the importance of the node. As I have a huge data and also the sizes of the nodes vary,they overlap over each other. I need to specify the distance between the sibling nodes.

I tried tree.separation() method but it didn't work.

Code is as follows :

tree.separation(seperator);

function seperator(a, b)
{
    if(a.parent == b.parent)
    {
        if((a.abundance == (maxAbd)) || (b.abundance == (maxAbd)))
        {
            return 2;
        }
        else
        {
            return 1;
        }
    }
}

This is giving me error saying:

Unexpected value translate(433.33333333333337,NaN) parsing transform attribute.

I understand that that after adding the separation method it is unable to calculate the x coordinate for the nodes. Can anyone please help me with how to do this?

I also tried modifying the source code as suggested in https://groups.google.com/forum/#!topic/d3-js/7Js0dGrnyek but that did not work either.

Please suggest some solution.

2 Answers
Related