Trying out the sample code for an XY plot in pygal involving datetime or date, any dates prior to 1970 cause this traceback:
Traceback (most recent call last):
File "C:/Users/***/dt_test.py", line 30, in <module>
datetimeline.render()
File "C:\Python\Python36\lib\site-packages\pygal\graph\public.py", line 52,
in render
self.setup(**kwargs)
File "C:\Python\Python36\lib\site-packages\pygal\graph\base.py", line 217,
in setup
self._draw()
File "C:\Python\Python36\lib\site-packages\pygal\graph\graph.py", line 924,
in _draw
self._compute_x_labels()
File "C:\Python\Python36\lib\site-packages\pygal\graph\dual.py", line 61,
in _compute_x_labels
self._x_labels = list(zip(map(self._x_format, x_pos), x_pos))
File "C:\Python\Python36\lib\site-packages\pygal\graph\time.py", line 103,
in datetime_to_str
dt = datetime.utcfromtimestamp(x)
OSError: [Errno 22] Invalid argument
Does anyone else get this behavior? (I'm using PyCharm.) lPerhaps the 'millennium' is returning an unexpected negative number?
(Edit) I used the code under "date", running in PyCharm:
from datetime import datetime
datetimeline = pygal.DateTimeLine(
x_label_rotation=35, truncate_label=-1,
x_value_formatter=lambda dt: dt.strftime('%d, %b %Y at %I:%M:%S %p'))
datetimeline.add("Serie", [
(datetime(2013, 1, 2, 12, 0), 300),
(datetime(2013, 1, 12, 14, 30, 45), 412),
(datetime(2013, 2, 2, 6), 823),
(datetime(2013, 2, 22, 9, 45), 672)
])
datetimeline.render()
... when I change the '2013' to '1969,' I get the Traceback shown above.