Skip to content

Commit b07de7b

Browse files
committed
feels weird
1 parent a9fe2a4 commit b07de7b

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

src/plots/plots.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3181,6 +3181,7 @@ function sortAxisCategoriesByValue(axList, gd) {
31813181
value = cdi.s;
31823182
if(value === undefined) value = cdi.v;
31833183
if(value === undefined) value = isX ? cdi.y : cdi.x;
3184+
31843185

31853186
if(!Array.isArray(value)) {
31863187
if(value === undefined) value = [];

src/traces/scatterquiver/calc.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,12 @@ module.exports = function calc(gd, trace) {
4545

4646
// For category aggregation, we need to set the right properties
4747
// The category aggregation looks for:
48-
// - catIndex = cdi.p (position) or cdi[axLetter] (x/y coordinate)
48+
// - catIndex = cdi.p (position) or cdi[axLetter] (x/y coordinate)
4949
// - value = cdi.s (size) or cdi.v (value) or opposite coordinate
50-
// We'll let the axis system handle the category index mapping
51-
cdi.s = Math.sqrt(u[i] * u[i] + v[i] * v[i]); // magnitude as size/value
52-
cdi.v = cdi.s; // also set v for value-based aggregation
50+
// For scatterquiver, use u component as the value for category ordering
51+
cdi.s = u[i]; // use u component for size/value
52+
cdi.v = u[i]; // use u component for value-based aggregation
53+
5354

5455
// Calculate arrow components for rendering
5556
var dx = u[i] * scale * (scaleRatio || 1);
@@ -100,6 +101,9 @@ function isNumeric(val) {
100101

101102
function calcAxisExpansion(gd, trace, xa, ya, x, y) {
102103
var serieslen = trace._length;
104+
var fullLayout = gd._fullLayout;
105+
var xId = xa._id;
106+
var yId = ya._id;
103107
var ppad = 0.1; // padding for arrows
104108

105109
// Calculate padding based on arrow lengths
@@ -112,6 +116,11 @@ function calcAxisExpansion(gd, trace, xa, ya, x, y) {
112116
}
113117
}
114118

115-
xa.expand(x, {ppad: ppad});
116-
ya.expand(y, {ppad: ppad});
119+
// Use the same approach as scatter trace
120+
var xOptions = {padded: true, ppad: ppad};
121+
var yOptions = {padded: true, ppad: ppad};
122+
123+
// N.B. asymmetric splom traces call this with blank {} xa or ya
124+
if(xId) trace._extremes[xId] = Axes.findExtremes(xa, x, xOptions);
125+
if(yId) trace._extremes[yId] = Axes.findExtremes(ya, y, yOptions);
117126
}

test/jasmine/tests/calcdata_test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -998,7 +998,7 @@ describe('calculated data and points', function() {
998998
}
999999
}
10001000

1001-
return Lib.extendDeep({}, {
1001+
var baseData = {
10021002
orientation: axName === 'yaxis' ? 'h' : 'v',
10031003
type: type,
10041004
x: cat,
@@ -1032,7 +1032,15 @@ describe('calculated data and points', function() {
10321032
values: b
10331033
}
10341034
]
1035-
});
1035+
};
1036+
1037+
// For scatterquiver, add u and v vector components
1038+
if(type === 'scatterquiver') {
1039+
baseData.u = data;
1040+
baseData.v = data;
1041+
}
1042+
1043+
return Lib.extendDeep({}, baseData);
10361044
}
10371045

10381046
supportedCartesianTraces.forEach(function(trace) {

0 commit comments

Comments
 (0)