pyqtgraph/pyqtgraph
Lev Maximov a76d9daec2
Date axis item (#1154)
* Add DateAxisItem

* Change style to camelCase

* Fix missing first tick for negative timestamps

* Add ms precision, auto skipping

Auto skipping allows a zoom level to skip ticks automatically if the
maximum number of ticks/pt is exceeded

* fixes suggested by @goetzc

* workaround for negative argument to utcfromtimestamp on windows

* attachToPlotItem method

* default date axis orientation

* Use new DateAxisItem in Plot Customization example

* attachToPlotItem bugfix

* examples of DateAxisItem

* modified description of customPlot example

* added descriptions to the new examples, reformatted their code, included the first one into utils.py

* typo

* Refactored code for setting axis items into new function

Replaces "DateAxisItem.attachToPlotItem"

* Fix string comparison with ==

* Doc: Slightly more text for DateAxisItem, small improvement for PlotItem

* Make PlotWidget.setAxisItems official

* Fix typo in docstring

* renamed an example

* merge bug fix

* Revert "merge bug fix"

This reverts commit 876b5a7cdb.

* Real bug fix

* support for dates upto -1e13..1e13

* Automatically limit DateAxisItem to a range from -1e12 to 1e12 years

Very large years (|y|>1e13) cause infinite loop, and since nobody
needs time 100 times larger than the age of the universe anyways,
this constrains it to 1e12.

Following suggestion by @axil:
https://github.com/pyqtgraph/pyqtgraph/pull/1154#issuecomment-612662168

* Also catch ValueErrors occuring on Linux before OverfloeErrors

While zooming out, before hitting OverflowErrors, utctimestamp
produces ValueErrors (at least on my Linux machine), so they
are also catched.

* Fix: Timestamp 0 corresponds to year 1970

For large years, x axis labels jump by 1970 years if it is not
accounted for timestamp 0 to be equal to year 1970.

* Fix: When zooming into extreme dates, OSError occurs

This commit catches the OSError like the other observed errors

* Disable stepping below years for dates outside *_REGULAR_TIMESTAMP

2 reasons: First: At least on my Linux machine, zooming into
those dates creates infinite loops. Second: Nobody needs
sub-year-precision for those extreme years anyways.

* Adapt zoom level sizes based on current font size and screen resolution

This is somewhat experimental. With this commit, no longer 60 px are
assumed as width for all zoom levels, but the current font and
display resolution are considered to calculate the width of ticks in
each zoom level. See the new function `updateZoomLevels` for
details.
Before calling this function, overridden functions `paint` and
`generateDrawSpecs` provide information over the current display
and font via `self.fontScaleFactor` and `self.fontMetrics`.

* Meaningful error meassage when adding axis to multiple PlotItems

As @axil noted in the DateAxisItem PR, currently users get a
segmentation fault when one tries to add an axis to multiple
PlotItems. This commit adds a meaningful RuntimeError message
for that case.

* setZoomLevelForDensity: Refactoring and calculating optimal spacing on the fly

* DateTimeAxis Fix: 1970 shows when zooming far out

* Refactoring: Make zoomLevels a customizable dict again

* updated the dateaxisitem example

* Fix: Get screen resolution in a way that also works for Qt 4

This is both a simplification in code and an improvement in backwards compatibility with Qt 4.

* DateAxisItem Fix: Also resolve time below 0.5 seconds

* unix line endings in examples

* DateTimeAxis Fix: For years < 1 and > 9999, stepping broke

Stepping was off by 1970 years for years < 1 and > 9999,
resulting in a gap in ticks visible when zooming out. Fixed by
subtracting the usual 1970 years.

* DateTimeAxis Fix: Zooming out too far causes infinite loop

Fixed by setting default limits to +/- 1e10 years. Should still
be enough.

* improved second dateaxisitem example

* 1..9999 years limit

* DateTimeAxis: Use OrderedDict to stay compatible with Python < 3-6

* DateAxisItem: Use font height to determine spacing for vertical axes

* window title

* added dateaxisitem.rst

* updated index.rst

Co-authored-by: Lukas Heiniger <lukas.heiniger@sed.ethz.ch>
Co-authored-by: Lev Maximov <lev.maximov@gmail.com>
Co-authored-by: 2xB <2xB@users.noreply.github.com>
2020-04-27 11:43:22 -07:00
..
canvas Qulogic py3 fixes (#1073) 2019-11-12 08:45:42 -08:00
console Qulogic py3 fixes (#1073) 2019-11-12 08:45:42 -08:00
dockarea Make DockArea compatible with Qt Designer (#158) 2019-09-13 23:08:28 -07:00
exporters SVGExporter: Correct image pixelation. 2020-04-08 01:14:36 +02:00
flowchart Miscellaneous doc fixups (#1142) 2020-04-03 10:06:25 -07:00
graphicsItems Date axis item (#1154) 2020-04-27 11:43:22 -07:00
GraphicsScene Qulogic py3 fixes (#1073) 2019-11-12 08:45:42 -08:00
imageview Merge pull request #1016 from 2xB/fix-862 2019-08-16 20:28:02 -07:00
metaarray Incorporated correction luke suggested 2019-11-21 08:46:25 -08:00
multiprocess Qulogic py3 fixes (#1073) 2019-11-12 08:45:42 -08:00
opengl Fix typo bug 2020-01-09 15:23:49 -06:00
parametertree Allowed actions to diplay title instead of name (#1069) 2019-11-19 20:05:45 -08:00
pixmaps Qulogic py3 fixes (#1073) 2019-11-12 08:45:42 -08:00
tests Test makeARGB with nans 2020-04-03 17:56:38 -07:00
util remove resolution test, have display information printed during debug step 2019-06-09 16:25:22 -07:00
widgets Date axis item (#1154) 2020-04-27 11:43:22 -07:00
__init__.py Date axis item (#1154) 2020-04-27 11:43:22 -07:00
colormap.py Fix: colormap: Support various arguments as color (#1014) 2019-08-17 20:38:05 -07:00
configfile.py Qulogic py3 fixes (#1073) 2019-11-12 08:45:42 -08:00
debug.py Merge master into develop (#981) 2019-08-16 20:16:01 -07:00
exceptionHandling.py Squashed commit of the following: 2014-08-07 09:03:26 -04:00
frozenSupport.py Added Travis CI support 2014-03-30 02:51:32 -04:00
functions.py remove second nanMask = np.isnan(data) 2020-04-03 17:56:38 -07:00
graphicsWindows.py Miscellaneous doc fixups (#1142) 2020-04-03 10:06:25 -07:00
ordereddict.py Don't use ORderedDict backport on python 3 2017-10-11 09:05:32 -07:00
pgcollections.py Merge master into develop (#981) 2019-08-16 20:16:01 -07:00
PlotData.py Added GLBarGraphItem example 2013-09-06 15:36:36 -04:00
Point.py Merge master into develop (#981) 2019-08-16 20:16:01 -07:00
ptime.py Merge master into develop (#981) 2019-08-16 20:16:01 -07:00
python2_3.py Qulogic py3 fixes (#1073) 2019-11-12 08:45:42 -08:00
Qt.py Replace default list arg with None 2020-04-11 20:15:00 -07:00
reload.py Qulogic py3 fixes (#1073) 2019-11-12 08:45:42 -08:00
SignalProxy.py FIX: fix disconnect method of SignalProxy class. 2019-06-28 10:59:03 -03:00
SRTTransform.py ROI tests pass with row-major axis order 2016-08-25 18:18:15 -07:00
SRTTransform3D.py typo fix in comment 2018-04-26 21:57:51 +02:00
ThreadsafeTimer.py Switching to relative imports to allow pyqtgraph to be imported under other names. 2013-12-22 02:08:39 -05:00
Transform3D.py Fix transform3D for pyside2 2018-05-23 21:30:02 -07:00
units.py Reorganized directory structure to be more standard 2012-12-25 00:43:31 -05:00
Vector.py Merge master into develop (#981) 2019-08-16 20:16:01 -07:00
WidgetGroup.py Merge master into develop (#981) 2019-08-16 20:16:01 -07:00