Browse Source

Fix old python

pull/158/merge 1.7.0
Florian Mounier 10 years ago
parent
commit
41186be872
  1. 8
      CHANGELOG
  2. 2
      pygal/__init__.py
  3. 2
      pygal/_compat.py
  4. 6
      pygal/graph/time.py
  5. 5
      pygal/test/test_date.py

8
CHANGELOG

@ -1,9 +1,9 @@
V 2.0.0 UNRELEASED V 2.0.0 UNRELEASED
Remove DateY and replace it by real XY datetime, date, time and timedelta support. Rework the ghost mechanism to come back to a more object oriented behavior (Maybe)
Introduce new XY configuration options: `xrange`, `x_value_formatter`
Rework the ghost mechanism to come back to a more object oriented behavior (WIP)
V 1.6.3 V 1.7.0
Remove DateY and replace it by real XY datetime, date, time and timedelta support. (#188)
Introduce new XY configuration options: `xrange`, `x_value_formatter`.
Add show_x_labels option to remove them and the x axis. Add show_x_labels option to remove them and the x axis.
Set print_values to False by default. Set print_values to False by default.
Fix secondary serie text values when None in data. (#192) Fix secondary serie text values when None in data. (#192)

2
pygal/__init__.py

@ -21,7 +21,7 @@ Pygal - A python svg graph plotting library
""" """
__version__ = '1.6.3' __version__ = '1.7.0'
import sys import sys
from pygal.config import Config from pygal.config import Config
from pygal.ghost import Ghost, REAL_CHARTS from pygal.ghost import Ghost, REAL_CHARTS

2
pygal/_compat.py

@ -63,7 +63,7 @@ def total_seconds(td):
return td.total_seconds() return td.total_seconds()
def to_timestamp(x): def timestamp(x):
if hasattr(x, 'timestamp'): if hasattr(x, 'timestamp'):
return x.timestamp() return x.timestamp()
else: else:

6
pygal/graph/time.py

@ -22,12 +22,12 @@ Various datetime line plot
from pygal.graph.xy import XY from pygal.graph.xy import XY
from datetime import datetime, date, time, timedelta from datetime import datetime, date, time, timedelta
from pygal._compat import to_timestamp from pygal._compat import timestamp, total_seconds
def datetime_to_timestamp(x): def datetime_to_timestamp(x):
if isinstance(x, datetime): if isinstance(x, datetime):
return to_timestamp(x) return timestamp(x)
return x return x
@ -45,7 +45,7 @@ def time_to_datetime(x):
def timedelta_to_seconds(x): def timedelta_to_seconds(x):
if isinstance(x, timedelta): if isinstance(x, timedelta):
return x.total_seconds() return total_seconds(x)
return x return x

5
pygal/test/test_date.py

@ -19,6 +19,7 @@
from pygal import DateLine, TimeLine, DateTimeLine, TimeDeltaLine from pygal import DateLine, TimeLine, DateTimeLine, TimeDeltaLine
from pygal.test.utils import texts from pygal.test.utils import texts
from datetime import datetime, date, time, timedelta from datetime import datetime, date, time, timedelta
import sys
def test_date(): def test_date():
@ -96,9 +97,9 @@ def test_timedelta():
]) ])
q = timedelta_chart.render_pyquery() q = timedelta_chart.render_pyquery()
assert list( assert list(
q(".axis.x text").map(texts)) == [ t for t in q(".axis.x text").map(texts) if t != '0:00:00'
) == [
'1 day, 3:46:40', '1 day, 3:46:40',
'2 days, 7:33:20', '2 days, 7:33:20',
'3 days, 11:20:00', '3 days, 11:20:00',

Loading…
Cancel
Save