Skip to content

Commit 41c1140

Browse files
committed
handle typed arrays in image trace
1 parent a9d21c9 commit 41c1140

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/traces/image/hover.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
var Fx = require('../../components/fx');
44
var Lib = require('../../lib');
5+
var isArrayOrTypedArray = Lib.isArrayOrTypedArray;
56
var constants = require('./constants');
67

78
module.exports = function hoverPoints(pointData, xval, yval) {
@@ -54,9 +55,9 @@ module.exports = function hoverPoints(pointData, xval, yval) {
5455
}
5556

5657
var text;
57-
if(Array.isArray(trace.hovertext) && Array.isArray(trace.hovertext[ny])) {
58+
if(isArrayOrTypedArray(trace.hovertext) && isArrayOrTypedArray(trace.hovertext[ny])) {
5859
text = trace.hovertext[ny][nx];
59-
} else if(Array.isArray(trace.text) && Array.isArray(trace.text[ny])) {
60+
} else if(isArrayOrTypedArray(trace.text) && isArrayOrTypedArray(trace.text[ny])) {
6061
text = trace.text[ny][nx];
6162
}
6263

src/traces/image/plot.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,11 @@ module.exports = function plot(gd, plotinfo, cdimage, imageLayer) {
186186
.then(function() {
187187
var href, canvas;
188188
if(trace._hasZ) {
189-
canvas = drawMagnifiedPixelsOnCanvas(function(i, j) {return z[j][i];});
189+
canvas = drawMagnifiedPixelsOnCanvas(function(i, j) {
190+
var _z = z[j][i];
191+
if(Lib.isTypedArray(_z)) _z = Array.from(_z);
192+
return _z;
193+
});
190194
href = canvas.toDataURL('image/png');
191195
} else if(trace._hasSource) {
192196
if(realImage) {

0 commit comments

Comments
 (0)