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

Limit the min zoom out factor along x axis to prevent date range error #500

Merged
merged 2 commits into from
Jan 2, 2020

Conversation

midhun-pm
Copy link
Contributor

@midhun-pm midhun-pm commented Dec 26, 2019

Fixes part of issue 415

@rahulporuri
Copy link
Contributor

While this change fixes the possibility of getting the exception when zooming out, I can still get the error if I

  1. zoom out to the max extent
  2. start scrolling towards the left.
/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/chaco/scales/safetime.py:37: UserWarning: Timestamp out of range.  Returning safe default value.
  warnings.warn("Timestamp out of range.  Returning safe default value.")
Traceback (most recent call last):
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/enable/qt4/base_window.py", line 213, in paintEvent
    self.handler.paintEvent(event)
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/enable/qt4/base_window.py", line 65, in paintEvent
    self._enable_window._paint(event)
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/enable/abstract_window.py", line 471, in _paint
    self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/enable/component.py", line 427, in draw
    self._draw(gc, view_bounds, mode)
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/enable/component.py", line 779, in _draw
    self._dispatch_draw(layer, gc, view_bounds, mode)
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/enable/container.py", line 273, in _dispatch_draw
    component._dispatch_draw(layer, gc, new_bounds, mode)
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/enable/component.py", line 799, in _dispatch_draw
    handler(gc, view_bounds, mode)
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/enable/component.py", line 887, in _draw_underlay
    underlay.overlay(self, gc, view_bounds, mode)
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/chaco/grid.py", line 307, in overlay
    self._compute_ticks(other_component)
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/chaco/grid.py", line 255, in _compute_ticks
    scale=scale)
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/chaco/scales_tick_generator.py", line 31, in get_ticks
    ticks = self.scale.ticks(data_low, data_high)
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/chaco/scales/scales.py", line 446, in ticks
    ticks = scale.ticks(start, end, numticks)
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/chaco/scales/time_scale.py", line 291, in ticks
    return trange(start, end, **{self.unit: self.val})
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/chaco/scales/time_scale.py", line 179, in trange
    return trange_years(start, end, value)
  File "/Users/rporuri/.edm/envs/chaco-test-3.6-pyqt/lib/python3.6/site-packages/chaco/scales/time_scale.py", line 137, in trange_years
    dt = datetime(dt_start.year-dyears, 1, 1, 0, 0, 0, 0)
ValueError: year 0 is out of range

@midhun-pm
Copy link
Contributor Author

While this change fixes the possibility of getting the exception when zooming out, I can still get the error if I

1. zoom out to the max extent

2. start scrolling towards the left.

Thanks for catching this, didn't notice it.

Fixed this by restricting the pan tool to available data along X

@shoeb-github
Copy link
Contributor

From #415, the demo breaks for these files too.

The following demos also break when the user zooms out too much
shell/dates.py
financial/correlations.py
financial/stock_prices.py

Copy link
Contributor

@corranwebster corranwebster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but only fixes one of the deoms listed in #415 - don't mark #415 as "fixed" in the description.

@midhun-pm midhun-pm merged commit eabfe82 into master Jan 2, 2020
@rahulporuri rahulporuri deleted the fix/demo_financial_plot_dates_zoomout_error branch October 27, 2020 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants