Skip to content

Commit f09536f

Browse files
committed
Use isArrayOrTypedArray
1 parent 4035d4d commit f09536f

File tree

10 files changed

+32
-24
lines changed

10 files changed

+32
-24
lines changed

src/traces/quiver/attributes.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,5 +254,3 @@ attrs.hovertemplate = extendFlat({}, hovertemplateAttrs({}, {
254254
}));
255255

256256
module.exports = attrs;
257-
258-

src/traces/quiver/calc.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = function calc(gd, trace) {
2929
var normMax = -Infinity;
3030
var cMin = Infinity;
3131
var cMax = -Infinity;
32-
var hasC = Array.isArray(trace.c);
32+
var hasC = Lib.isArrayOrTypedArray(trace.c);
3333

3434
for(var i = 0; i < len; i++) {
3535
var cdi = cd[i] = { i: i };
@@ -75,5 +75,3 @@ module.exports = function calc(gd, trace) {
7575

7676
return cd;
7777
};
78-
79-

src/traces/quiver/defaults.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
1919
var v = coerce('v');
2020

2121
// Simple validation - check if we have the required arrays
22-
if(!x || !Array.isArray(x) || x.length === 0 ||
23-
!y || !Array.isArray(y) || y.length === 0) {
22+
// Use Lib.isArrayOrTypedArray to support both regular arrays and typed arrays
23+
if(!x || !Lib.isArrayOrTypedArray(x) || x.length === 0 ||
24+
!y || !Lib.isArrayOrTypedArray(y) || y.length === 0) {
2425
traceOut.visible = false;
2526
return;
2627
}
2728

2829
// If u/v are missing, default to zeros so the trace participates in calc/category logic
2930
var len = Math.min(x.length, y.length);
30-
if(!Array.isArray(u) || u.length === 0) {
31+
if(!Lib.isArrayOrTypedArray(u) || u.length === 0) {
3132
traceOut.u = new Array(len);
3233
for(var i = 0; i < len; i++) traceOut.u[i] = 0;
3334
}
34-
if(!Array.isArray(v) || v.length === 0) {
35+
if(!Lib.isArrayOrTypedArray(v) || v.length === 0) {
3536
traceOut.v = new Array(len);
3637
for(var j = 0; j < len; j++) traceOut.v[j] = 0;
3738
}
@@ -86,5 +87,3 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
8687
// Set the data length
8788
traceOut._length = len;
8889
};
89-
90-

src/traces/quiver/event_data.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,3 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) {
88
out.pointNumber = pointNumber;
99
out.trace = trace;
1010
};
11-
12-

src/traces/quiver/format_labels.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'use strict';
2+
3+
var Axes = require('../../plots/cartesian/axes');
4+
5+
module.exports = function formatLabels(cdi, trace, fullLayout) {
6+
var labels = {};
7+
8+
var xa = Axes.getFromId({ _fullLayout: fullLayout }, trace.xaxis || 'x');
9+
var ya = Axes.getFromId({ _fullLayout: fullLayout }, trace.yaxis || 'y');
10+
11+
var x = cdi.x;
12+
var y = cdi.y;
13+
14+
labels.xLabel = Axes.tickText(xa, xa.c2l(x), true).text;
15+
labels.yLabel = Axes.tickText(ya, ya.c2l(y), true).text;
16+
17+
var u = trace.u ? trace.u[cdi.i] : 0;
18+
var v = trace.v ? trace.v[cdi.i] : 0;
19+
20+
// Format u and v as plain numbers
21+
labels.uLabel = String(u);
22+
labels.vLabel = String(v);
23+
24+
return labels;
25+
};

src/traces/quiver/hover.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,3 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
7373

7474
return [hoverPoint];
7575
};
76-
77-

src/traces/quiver/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,3 @@ module.exports = {
2929
].join(' ')
3030
}
3131
};
32-
33-

src/traces/quiver/plot.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
191191
lineSegments.style('stroke', function(cdi) {
192192
var cArr = trace.c;
193193
var value;
194-
if (Array.isArray(cArr) && cArr.length > cdi.i && isFinite(cArr[cdi.i])) {
194+
if (Lib.isArrayOrTypedArray(cArr) && cArr.length > cdi.i && isFinite(cArr[cdi.i])) {
195195
value = cArr[cdi.i];
196196
} else {
197197
var uVal = (trace.u && trace.u[cdi.i]) || 0;
@@ -212,5 +212,3 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
212212
.style('opacity', 1);
213213
}
214214
}
215-
216-

src/traces/quiver/select_points.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,3 @@ module.exports = function selectPoints(searchInfo, selectionTester) {
3737

3838
return selection;
3939
};
40-
41-

src/traces/quiver/style.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,3 @@ module.exports = function style(gd, calcTrace) {
1414
s.selectAll('path.js-line')
1515
.call(Drawing.lineGroupStyle, trace.line || {});
1616
};
17-
18-

0 commit comments

Comments
 (0)