Skip to content

Commit 2558160

Browse files
committed
Fix static canvas dimensions
1 parent 7f1527f commit 2558160

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/plots/gl2d/scene2d.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,27 @@ proto.toImage = function(format) {
169169
this.stopped = true;
170170
if(this.staticPlot) this.container.appendChild(STATIC_CANVAS);
171171

172+
173+
174+
var glplot = this.glplot,
175+
pixelRatio = this.pixelRatio;
176+
177+
let fullLayout = this.fullLayout;
178+
179+
var width = fullLayout.width,
180+
height = fullLayout.height,
181+
pixelWidth = Math.ceil(pixelRatio * width) |0,
182+
pixelHeight = Math.ceil(pixelRatio * height) |0;
183+
184+
// check for resize
185+
var canvas = this.canvas;
186+
if(canvas.width !== pixelWidth || canvas.height !== pixelHeight) {
187+
canvas.width = pixelWidth;
188+
canvas.height = pixelHeight;
189+
}
190+
191+
192+
172193
// force redraw
173194
this.glplot.setDirty();
174195
this.glplot.draw();

0 commit comments

Comments
 (0)