adjusts html canvas backend size using dpr #147
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using get_bounding_client_rect to get the html canvas size causes the graph to be incorrectly sized if certain ccs styling is applied to the canvas.
For example, if you use css to scale a chart, get_bounding_client_rect will return the size to which the canvas will be scaled, not the actual size of the canvas. This causes the plot to be drawn with the wrong dimensions if the css scaling isn't set to the precise values which compensate for the dpr, either clipping off the canvas if it is scaled up, or only taking up part of the canvas if it is scaled down.
To address this issue, I use the device pixel ratio to properly adjust the size of the canvas for high DPI screens.
This is essential for resizing graphs without re-rendering them.