Works out the transform that brings a whole laid-out graph inside the canvas.
A force simulation spreads as far as its nodes push each other and knows nothing about the
size of the box it is drawn in, so without this the graph simply runs off the edges. This
measures what was actually laid out — pill widths and the labels hanging below nodes
included — and centres it at the largest scale that still fits. A graph too vast to fit
even at minScale stops shrinking there instead: it is left to be panned rather than
squeezed down to dust.
Works out the transform that brings a whole laid-out graph inside the canvas.
A force simulation spreads as far as its nodes push each other and knows nothing about the size of the box it is drawn in, so without this the graph simply runs off the edges. This measures what was actually laid out — pill widths and the labels hanging below nodes included — and centres it at the largest scale that still fits. A graph too vast to fit even at
minScalestops shrinking there instead: it is left to be panned rather than squeezed down to dust.