Skip to content

Commit 4b50e16

Browse files
committed
handle typed arrays various traces
1 parent 41c1140 commit 4b50e16

File tree

15 files changed

+26
-21
lines changed

15 files changed

+26
-21
lines changed

src/traces/bar/cross_trace_calc.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,9 @@ function setBarCenterAndWidth(pa, sieve) {
432432
var calcTrace = calcTraces[i];
433433
var t = calcTrace[0].t;
434434
var poffset = t.poffset;
435-
var poffsetIsArray = Array.isArray(poffset);
435+
var poffsetIsArray = isArrayOrTypedArray(poffset);
436436
var barwidth = t.barwidth;
437-
var barwidthIsArray = Array.isArray(barwidth);
437+
var barwidthIsArray = isArrayOrTypedArray(barwidth);
438438

439439
for(var j = 0; j < calcTrace.length; j++) {
440440
var calcBar = calcTrace[j];
@@ -478,8 +478,8 @@ function updatePositionAxis(pa, sieve, allowMinDtick) {
478478
var t = calcTrace0.t;
479479
var poffset = t.poffset;
480480
var barwidth = t.barwidth;
481-
var poffsetIsArray = Array.isArray(poffset);
482-
var barwidthIsArray = Array.isArray(barwidth);
481+
var poffsetIsArray = isArrayOrTypedArray(poffset);
482+
var barwidthIsArray = isArrayOrTypedArray(barwidth);
483483

484484
for(j = 0; j < calcTrace.length; j++) {
485485
bar = calcTrace[j];
@@ -750,7 +750,7 @@ function collectExtents(calcTraces, pa) {
750750
cd[0].t.extents = extents;
751751

752752
var poffset = cd[0].t.poffset;
753-
var poffsetIsArray = Array.isArray(poffset);
753+
var poffsetIsArray = isArrayOrTypedArray(poffset);
754754

755755
for(j = 0; j < cd.length; j++) {
756756
var di = cd[j];

src/traces/cone/convert.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var createConeMesh = require('../../../stackgl_modules').gl_cone3d.createConeMes
66
var simpleMap = require('../../lib').simpleMap;
77
var parseColorScale = require('../../lib/gl_format_color').parseColorScale;
88
var extractOpts = require('../../components/colorscale').extractOpts;
9+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
910
var zip3 = require('../../plots/gl3d/zip3');
1011

1112
function Cone(scene, uid) {
@@ -34,7 +35,7 @@ proto.handlePick = function(selection) {
3435
];
3536

3637
var text = this.data.hovertext || this.data.text;
37-
if(Array.isArray(text) && text[selectIndex] !== undefined) {
38+
if(isArrayOrTypedArray(text) && text[selectIndex] !== undefined) {
3839
selection.textLabel = text[selectIndex];
3940
} else if(text) {
4041
selection.textLabel = text;

src/traces/funnel/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
4444
});
4545

4646
if(traceOut.textposition !== 'none' && !traceOut.texttemplate) {
47-
coerce('textinfo', Array.isArray(text) ? 'text+value' : 'value');
47+
coerce('textinfo', Lib.isArrayOrTypedArray(text) ? 'text+value' : 'value');
4848
}
4949

5050
var markerColor = coerce('marker.color', defaultColor);

src/traces/icicle/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
4040

4141
var text = coerce('text');
4242
coerce('texttemplate');
43-
if(!traceOut.texttemplate) coerce('textinfo', Array.isArray(text) ? 'text+label' : 'label');
43+
if(!traceOut.texttemplate) coerce('textinfo', Lib.isArrayOrTypedArray(text) ? 'text+label' : 'label');
4444

4545
coerce('hovertext');
4646
coerce('hovertemplate');

src/traces/isosurface/convert.js

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

33
var createMesh = require('../../../stackgl_modules').gl_mesh3d;
44
var parseColorScale = require('../../lib/gl_format_color').parseColorScale;
5+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
56
var str2RgbaArray = require('../../lib/str2rgbarray');
67
var extractOpts = require('../../components/colorscale').extractOpts;
78
var zip3 = require('../../plots/gl3d/zip3');
@@ -59,7 +60,7 @@ proto.handlePick = function(selection) {
5960
];
6061

6162
var text = this.data.hovertext || this.data.text;
62-
if(Array.isArray(text) && text[selectIndex] !== undefined) {
63+
if(isArrayOrTypedArray(text) && text[selectIndex] !== undefined) {
6364
selection.textLabel = text[selectIndex];
6465
} else if(text) {
6566
selection.textLabel = text;

src/traces/mesh3d/convert.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var alphaShape = require('../../../stackgl_modules').alpha_shape;
66
var convexHull = require('../../../stackgl_modules').convex_hull;
77

88
var parseColorScale = require('../../lib/gl_format_color').parseColorScale;
9+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
910
var str2RgbaArray = require('../../lib/str2rgbarray');
1011
var extractOpts = require('../../components/colorscale').extractOpts;
1112
var zip3 = require('../../plots/gl3d/zip3');
@@ -37,7 +38,7 @@ proto.handlePick = function(selection) {
3738
}
3839

3940
var text = this.data.hovertext || this.data.text;
40-
if(Array.isArray(text) && text[selectIndex] !== undefined) {
41+
if(isArrayOrTypedArray(text) && text[selectIndex] !== undefined) {
4142
selection.textLabel = text[selectIndex];
4243
} else if(text) {
4344
selection.textLabel = text;

src/traces/ohlc/calc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ function calcCommon(gd, trace, origX, x, ya, ptFunc) {
5050
var l = ya.makeCalcdata(trace, 'low');
5151
var c = ya.makeCalcdata(trace, 'close');
5252

53-
var hasTextArray = Array.isArray(trace.text);
54-
var hasHovertextArray = Array.isArray(trace.hovertext);
53+
var hasTextArray = Lib.isArrayOrTypedArray(trace.text);
54+
var hasHovertextArray = Lib.isArrayOrTypedArray(trace.hovertext);
5555

5656
// we're optimists - before we have any changing data, assume increasing
5757
var increasing = true;

src/traces/pointcloud/convert.js

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

33
var createPointCloudRenderer = require('../../../stackgl_modules').gl_pointcloud2d;
44

5+
var isArrayOrTypedArray = require('../../lib').isArrayOrTypedArray;
56
var str2RGBArray = require('../../lib/str2rgbarray');
67
var findExtremes = require('../../plots/cartesian/autorange').findExtremes;
78
var getTraceColor = require('../scatter/get_trace_color');
@@ -48,7 +49,7 @@ proto.handlePick = function(pickResult) {
4849
traceCoord: this.pickXYData ?
4950
[this.pickXYData[index * 2], this.pickXYData[index * 2 + 1]] :
5051
[this.pickXData[index], this.pickYData[index]],
51-
textLabel: Array.isArray(this.textLabels) ?
52+
textLabel: isArrayOrTypedArray(this.textLabels) ?
5253
this.textLabels[index] :
5354
this.textLabels,
5455
color: this.color,

src/traces/scatter/hover.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
199199

200200
delete pointData.index;
201201

202-
if(trace.text && !Array.isArray(trace.text)) {
202+
if(trace.text && !Lib.isArrayOrTypedArray(trace.text)) {
203203
pointData.text = String(trace.text);
204204
} else pointData.text = trace.name;
205205

src/traces/scatter3d/convert.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ proto.handlePick = function(selection) {
5858

5959
selection.textLabel = '';
6060
if(this.textLabels) {
61-
if(Array.isArray(this.textLabels)) {
61+
if(Lib.isArrayOrTypedArray(this.textLabels)) {
6262
if(this.textLabels[ind] || this.textLabels[ind] === 0) {
6363
selection.textLabel = this.textLabels[ind];
6464
}
@@ -227,7 +227,7 @@ function convertPlotlyOptions(scene, data) {
227227
}
228228

229229
// convert text
230-
if(Array.isArray(data.text)) text = data.text;
230+
if(Lib.isArrayOrTypedArray(data.text)) text = data.text;
231231
else if(data.text !== undefined) {
232232
text = new Array(len);
233233
for(i = 0; i < len; i++) text[i] = data.text;

0 commit comments

Comments
 (0)