Update patch set 1
Patch Set 1: Code-Review-1
The problem is not here, in this code, but in the CSS of https://tools.wmflabs.org/scholia/author/Q27061849 . The <div> container there that is meant to display the dimensions graph does not have any size constraints. The result browser does it's best to guess what the dimensions might be, and calculates a number, but this number changes immediately the moment the graph is attached to the <div>. The <div> changes size and starts showing scrollbars, and these reduce the width (but not the height).
Note this is different depending on the operating system. As far as I know the scrollbars on Apple touch devices do not consume space.
Much better solution: Set a fixed height on the <div> container, and set "overflow: hidden" just to be sure.