Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented single_axis option as described in documentation. #293

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions chaco/tools/drag_zoom.py
Original file line number Diff line number Diff line change
@@ -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

4 changes: 4 additions & 0 deletions chaco/tools/range_selection.py
Original file line number Diff line number Diff line change
@@ -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)