Skip to content

Commit 1909034

Browse files
committed
hide outside range points on drag and transitions
1 parent 8f72d1f commit 1909034

File tree

3 files changed

+37
-19
lines changed

3 files changed

+37
-19
lines changed

src/components/drawing/index.js

+11
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ drawing.hideOutsideRangePoint = function(d, sel, xa, ya) {
100100
);
101101
};
102102

103+
drawing.hideOutsideRangePoints = function(points, subplot) {
104+
if(!subplot._hasClipOnAxisFalse) return;
105+
106+
var xa = subplot.xaxis;
107+
var ya = subplot.yaxis;
108+
109+
points.each(function(d) {
110+
drawing.hideOutsideRangePoint(d, d3.select(this), xa, ya);
111+
});
112+
};
113+
103114
drawing.getPx = function(s, styleAttr) {
104115
// helper to pull out a px value from a style that may contain px units
105116
// s is a d3 selection (will pull from the first one)

src/plots/cartesian/dragbox.js

+14-11
Original file line numberDiff line numberDiff line change
@@ -747,19 +747,22 @@ module.exports = function dragBox(gd, plotinfo, x, y, w, h, ns, ew) {
747747
.call(Drawing.setTranslate, clipDx, clipDy)
748748
.call(Drawing.setScale, xScaleFactor2, yScaleFactor2);
749749

750+
var scatterPoints = subplot.plot.select('.scatterlayer').selectAll('.points');
751+
750752
subplot.plot
751753
.call(Drawing.setTranslate, plotDx, plotDy)
752-
.call(Drawing.setScale, 1 / xScaleFactor2, 1 / yScaleFactor2)
753-
754-
// This is specifically directed at scatter traces, applying an inverse
755-
// scale to individual points to counteract the scale of the trace
756-
// as a whole:
757-
.select('.scatterlayer').selectAll('.points').selectAll('.point')
758-
.call(Drawing.setPointGroupScale, xScaleFactor2, yScaleFactor2);
759-
760-
subplot.plot.select('.scatterlayer')
761-
.selectAll('.points').selectAll('.textpoint')
762-
.call(Drawing.setTextPointsScale, xScaleFactor2, yScaleFactor2);
754+
.call(Drawing.setScale, 1 / xScaleFactor2, 1 / yScaleFactor2);
755+
756+
// This is specifically directed at scatter traces, applying an inverse
757+
// scale to individual points to counteract the scale of the trace
758+
// as a whole:
759+
scatterPoints.selectAll('.point')
760+
.call(Drawing.setPointGroupScale, xScaleFactor2, yScaleFactor2)
761+
.call(Drawing.hideOutsideRangePoints, subplot);
762+
763+
scatterPoints.selectAll('.textpoint')
764+
.call(Drawing.setTextPointsScale, xScaleFactor2, yScaleFactor2)
765+
.call(Drawing.hideOutsideRangePoints, subplot);
763766
}
764767
}
765768

src/plots/cartesian/transition_axes.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,20 @@ module.exports = function transitionAxes(gd, newLayout, transitionOpts, makeOnCo
143143

144144
subplot.plot
145145
.call(Drawing.setTranslate, xa2._offset, ya2._offset)
146-
.call(Drawing.setScale, 1, 1)
146+
.call(Drawing.setScale, 1, 1);
147147

148-
// This is specifically directed at scatter traces, applying an inverse
149-
// scale to individual points to counteract the scale of the trace
150-
// as a whole:
151-
.select('.scatterlayer').selectAll('.points').selectAll('.point')
152-
.call(Drawing.setPointGroupScale, 1, 1);
148+
var scatterPoints = subplot.plot.select('.scatterlayer').selectAll('.points');
149+
150+
// This is specifically directed at scatter traces, applying an inverse
151+
// scale to individual points to counteract the scale of the trace
152+
// as a whole:
153+
scatterPoints.selectAll('.point')
154+
.call(Drawing.setPointGroupScale, 1, 1)
155+
.call(Drawing.hideOutsideRangePoints, subplot);
153156

154-
subplot.plot.select('.scatterlayer').selectAll('.points').selectAll('.textpoint')
155-
.call(Drawing.setTextPointsScale, 1, 1);
157+
scatterPoints.selectAll('.textpoint')
158+
.call(Drawing.setTextPointsScale, 1, 1)
159+
.call(Drawing.hideOutsideRangePoints, subplot);
156160
}
157161

158162
function updateSubplot(subplot, progress) {

0 commit comments

Comments
 (0)