Instead of having a fixed tree size, I am experimenting with using nodeSize for automatic spacing of nodes on a horizontal tree.
So instead of:
var tree = d3.layout.tree().size([height, width]);
Using:
var tree = d3.layout.tree().nodeSize([height, width]);
See D3 Tree Layout Separation Between Nodes using NodeSize
An issue arises though when the number of child and cousin nodes makes the tree too large vertically for the viewable area.
This begs for an auto zoom function when the tree is expanded if the tree exceeds the viewable bounds of the viewable area.
How would an auto zoom be applied so that the tree is zoomed or scaled to fit the viewable area? Perhaps something similar to d3.js force layout auto zoom/scale after loading
The fiddle below has a parent node with 40 child nodes with tree size determined by nodeSize. When expanded, the tree exceeds the viewable area. The tree also has manual zoom and pan. I am using d3.js version 3.4.11 at the moment.