Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf50f12

Browse files
authored
Merge pull request#18142 from QuLogic/fix-nbagg-chrome84
Fix nbagg in Chrome 84
2 parents3e75187 +d965261 commitdf50f12

File tree

1 file changed

+25
-4
lines changed
  • lib/matplotlib/backends/web_backend/js

1 file changed

+25
-4
lines changed

‎lib/matplotlib/backends/web_backend/js/mpl.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,37 @@ mpl.figure.prototype._init_canvas = function () {
172172
varentry=entries[i];
173173
varwidth,height;
174174
if(entry.contentBoxSize){
175-
width=entry.contentBoxSize.inlineSize;
176-
height=entry.contentBoxSize.blockSize;
175+
if(entry.contentBoxSizeinstanceofArray){
176+
// Chrome 84 implements new version of spec.
177+
width=entry.contentBoxSize[0].inlineSize;
178+
height=entry.contentBoxSize[0].blockSize;
179+
}else{
180+
// Firefox implements old version of spec.
181+
width=entry.contentBoxSize.inlineSize;
182+
height=entry.contentBoxSize.blockSize;
183+
}
177184
}else{
185+
// Chrome <84 implements even older version of spec.
178186
width=entry.contentRect.width;
179187
height=entry.contentRect.height;
180188
}
181189

182190
// Keep the size of the canvas and rubber band canvas in sync with
183191
// the canvas container.
184-
canvas.setAttribute('width',width*mpl.ratio);
185-
canvas.setAttribute('height',height*mpl.ratio);
192+
if(entry.devicePixelContentBoxSize){
193+
// Chrome 84 implements new version of spec.
194+
canvas.setAttribute(
195+
'width',
196+
entry.devicePixelContentBoxSize[0].inlineSize
197+
);
198+
canvas.setAttribute(
199+
'height',
200+
entry.devicePixelContentBoxSize[0].blockSize
201+
);
202+
}else{
203+
canvas.setAttribute('width',width*mpl.ratio);
204+
canvas.setAttribute('height',height*mpl.ratio);
205+
}
186206
canvas.setAttribute(
187207
'style',
188208
'width: '+width+'px; height: '+height+'px;'
@@ -254,6 +274,7 @@ mpl.figure.prototype._init_canvas = function () {
254274

255275
// Disable right mouse context menu.
256276
this.rubberband_canvas.addEventListener('contextmenu',function(_e){
277+
event.preventDefault();
257278
returnfalse;
258279
});
259280

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp