Skip to content

Commit 9b79b3f

Browse files
committed
add support for selection of aggregations
- similar to pointNumber and pointNumbers, make the distinction between 1-to-1 input to selection/hovered pt and many-to-1 maps like for histogram traces and aggregation transforms.
1 parent 315e632 commit 9b79b3f

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/components/fx/helpers.js

+11
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ exports.makeEventData = function makeEventData(pt, trace, cd) {
111111
pointNumber: pointNumber
112112
};
113113

114+
if(trace._indexToPoints) {
115+
var pointIndices = trace._indexToPoints[pointNumber];
116+
117+
if(pointIndices.length === 1) {
118+
out.pointIndex = pointIndices[0];
119+
} else {
120+
out.pointIndices = pointIndices;
121+
}
122+
} else {
123+
out.pointIndex = pointNumber;
124+
}
114125

115126
if(trace._module.eventData) {
116127
out = trace._module.eventData(out, pt, trace, cd, pointNumber);

src/plots/cartesian/select.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,13 @@ function updateSelectedState(gd, searchTraces, eventData) {
308308
var data = pt.data;
309309
var fullData = pt.fullData;
310310

311-
data.selectedpoints.push(pt.pointIndex);
312-
fullData.selectedpoints.push(pt.pointIndex);
311+
if(pt.pointIndices) {
312+
data.selectedpoints = data.selectedpoints.concat(pt.pointIndices);
313+
fullData.selectedpoints = fullData.selectedpoints.concat(pt.pointIndices);
314+
} else {
315+
data.selectedpoints.push(pt.pointIndex);
316+
fullData.selectedpoints.push(pt.pointIndex);
317+
}
313318
}
314319
}
315320
else {

src/traces/histogram/event_data.js

+13
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ module.exports = function eventData(out, pt, trace, cd, pointNumber) {
2525
out.pointNumbers = pts;
2626
out.binNumber = out.pointNumber;
2727
delete out.pointNumber;
28+
delete out.pointIndex;
29+
30+
var pointIndices;
31+
if(trace._indexToPoints) {
32+
pointIndices = [];
33+
for(var i = 0; i < pts.length; i++) {
34+
pointIndices = pointIndices.concat(trace._indexToPoints[pts[i]]);
35+
}
36+
} else {
37+
pointIndices = pts;
38+
}
39+
40+
out.pointIndices = pointIndices;
2841
}
2942

3043
return out;

0 commit comments

Comments
 (0)