Skip to content

Commit 3e81eca

Browse files
committed
fallbacks for ie9 are better than typedarray polyfill
but it works this way with the polyfill too.
1 parent 74dbbc4 commit 3e81eca

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/lib/is_array.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
/**
1212
* Return true for arrays, whether they're untyped or not.
1313
*/
14+
15+
// IE9 fallback
16+
var ab = (typeof ArrayBuffer === 'undefined' || !ArrayBuffer.isView) ?
17+
{isView: function() { return false; }} :
18+
ArrayBuffer;
19+
1420
module.exports = function isArray(a) {
15-
return Array.isArray(a) || ArrayBuffer.isView(a);
21+
return Array.isArray(a) || ab.isView(a);
1622
};

src/traces/heatmap/plot.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,14 @@ function plotOne(gd, plotinfo, cd) {
337337

338338
if(zsmooth) { // best or fast, works fastest with imageData
339339
var pxIndex = 0,
340+
pixels;
341+
342+
try {
340343
pixels = new Uint8Array(imageWidth * imageHeight * 4);
344+
}
345+
catch(e) {
346+
pixels = new Array(imageWidth * imageHeight * 4);
347+
}
341348

342349
if(zsmooth === 'best') {
343350
var xPixArray = new Array(x.length),
@@ -379,7 +386,17 @@ function plotOne(gd, plotinfo, cd) {
379386
}
380387

381388
var imageData = context.createImageData(imageWidth, imageHeight);
382-
imageData.data.set(pixels);
389+
try {
390+
imageData.data.set(pixels);
391+
}
392+
catch(e) {
393+
var pxArray = imageData.data,
394+
dlen = pxArray.length;
395+
for(j = 0; j < dlen; j ++) {
396+
pxArray[j] = pixels[j];
397+
}
398+
}
399+
383400
context.putImageData(imageData, 0, 0);
384401
} else { // zsmooth = false -> filling potentially large bricks works fastest with fillRect
385402
for(j = 0; j < m; j++) {

0 commit comments

Comments
 (0)