diff --git a/chaco/tools/drag_zoom.py b/chaco/tools/drag_zoom.py index bad8d56dd..ddd9da7f5 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,22 @@ 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: + # Zoom only along specified axis + flip = self.component.orientation=='v' + if self.axis == 'index': + if flip: + self.zoom_in_y(zoom_y) + else: + self.zoom_in_x(zoom_x) + if self.axis == 'value': + if flip: + self.zoom_in_x(zoom_x) + else: + self.zoom_in_y(zoom_y) return 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)