Setting variable width on d3 tree nodes - TechRepublic
Question
March 9, 2017 at 07:28 PM
vomaus94

Setting variable width on d3 tree nodes

by vomaus94 . Updated 9 years, 2 months ago

I’m using d3 to create an Org Chart, which has some nodes with longer names.

I’ve managed to modify the width of longer nodes, but have trouble properly placing their children and the lines (paths) to their children. I tried calculating myself with determineChildXValue(), but that didn’t work properly.

Is there a way to initialize the tree with variable widths so it will take care of the calculations of translations for child nodes?

Currently, I’m initializing it with hard-coded node sizes:

var tree = d3.layout.tree().nodeSize([70, 40]);
I’ve replicated the behavior at https://jsbin.com/yelogam/edit?html,js,output – expand Departments, then DEPARTMENT STORES to see the overlap.

Thanks in advance!

This discussion is locked

All Comments