From 77d6dd662aa7cf239051c9b6b2d78f8f5190c564 Mon Sep 17 00:00:00 2001 From: dianeoyen Date: Wed, 30 Mar 2016 09:49:41 -0600 Subject: [PATCH 1/3] Implemented single_axis option as described in documentation. The single_axis option was not implemented previously, although the option exists and is described by documentation. --- chaco/tools/drag_zoom.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/chaco/tools/drag_zoom.py b/chaco/tools/drag_zoom.py index bad8d56dd..517148ea8 100644 --- a/chaco/tools/drag_zoom.py +++ b/chaco/tools/drag_zoom.py @@ -81,7 +81,7 @@ def dragging(self, event): # Compute the zoom amount based on the pixel difference between # the previous mouse event and the current one. - if self.maintain_aspect_ratio: + if self.maintain_aspect_ratio or self.single_axis: zoom_x = zoom_y = self._calc_zoom(self._prev_y, event.y) else: zoom_x = self._calc_zoom(self._prev_x, event.x) @@ -91,8 +91,14 @@ def dragging(self, event): zoom_x = 1.0/zoom_x zoom_y = 1.0/zoom_y - self.zoom_in_x(zoom_x) - self.zoom_in_y(zoom_y) + if not self.single_axis: + self.zoom_in_x(zoom_x) + self.zoom_in_y(zoom_y) + else: + if self.axis == 'index': + self.zoom_in_x(zoom_x) + if self.axis == 'value': + self.zoom_in_y(zoom_y) return From 933d836d3aed35fd0eec98704024c9dbab54413a Mon Sep 17 00:00:00 2001 From: dianeoyen Date: Tue, 12 Apr 2016 10:08:34 -0600 Subject: [PATCH 2/3] Updated single_axis option for vertical orientation --- chaco/tools/drag_zoom.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/chaco/tools/drag_zoom.py b/chaco/tools/drag_zoom.py index 517148ea8..ddd9da7f5 100644 --- a/chaco/tools/drag_zoom.py +++ b/chaco/tools/drag_zoom.py @@ -94,11 +94,19 @@ def dragging(self, event): if not self.single_axis: self.zoom_in_x(zoom_x) self.zoom_in_y(zoom_y) - else: + else: + # Zoom only along specified axis + flip = self.component.orientation=='v' if self.axis == 'index': - self.zoom_in_x(zoom_x) + if flip: + self.zoom_in_y(zoom_y) + else: + self.zoom_in_x(zoom_x) if self.axis == 'value': - self.zoom_in_y(zoom_y) + if flip: + self.zoom_in_x(zoom_x) + else: + self.zoom_in_y(zoom_y) return From e23b5fd700df9faff5a95a0ff9f8c83a26f7d167 Mon Sep 17 00:00:00 2001 From: dianeoyen Date: Tue, 12 Apr 2016 10:31:40 -0600 Subject: [PATCH 3/3] Fixed de-selection of scatterplot points. When no points are selected, delete the datasource metadata for 'selection_masks'. --- chaco/tools/range_selection.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chaco/tools/range_selection.py b/chaco/tools/range_selection.py index 8d6146bc3..2433dc472 100644 --- a/chaco/tools/range_selection.py +++ b/chaco/tools/range_selection.py @@ -613,6 +613,10 @@ def _set_selection(self, val): new_mask = (data_pts >= low) & (data_pts <= high) selection_masks.append(new_mask) self._selection_mask = new_mask + else: + # Reset datasource metadata if no points selected + del datasource.metadata[self.mask_metadata_name] + datasource.metadata_changed = {self.mask_metadata_name: val} self.trait_property_changed("selection", oldval, val)