paper.fitToContent([opt])

Expand or shrink the paper to fit the content inside it. The method returns the area (g.Rect) of the paper after fitting in local coordinates.

The function accepts an object with additional settings (all optional):

You can try many of these options interactively in the paper demo.

This method might internally trigger the "resize" and "translate" events. These can be handled by listening on the paper object (paper.on('resize', myHandler)).

paper.fitToContent([gridWidth, gridHeight, padding, opt])

Depracated usage. All parameters are expected to be passed inside the opt object.