If dynazoom is available it should try to fill the whole usable area with graph values. That should be easy to compute, by getting the image size from a graph requested with e.g. 10px height, and subtracting this from the available height to compensate for the varying heights of the legend.