From f3c6b1bd85b8c0a1691ddd7a3548e1c750acc632 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Wed, 2 Sep 2015 16:05:48 +0200 Subject: [PATCH] Avoid x label formatting when label is a string --- demo/moulinrouge/tests.py | 2 +- docs/changelog.rst | 5 +++++ pygal/__init__.py | 2 +- pygal/graph/graph.py | 8 +++++++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index 26d7f6f..183b007 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -37,7 +37,7 @@ def get_test_routes(app): @app.route('/test/unsorted') def test_unsorted(): - bar = Bar(style=styles['neon']) + bar = Bar(style=styles['neon'], human_readable=True) bar.add('A', {'red': 10, 'green': 12, 'blue': 14}) bar.add('B', {'green': 11, 'blue': 7}) bar.add('C', {'blue': 7}) diff --git a/docs/changelog.rst b/docs/changelog.rst index 400c272..049990c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,6 +2,11 @@ Changelog ========= +2.0.6 +===== + +* Avoid x label formatting when label is a string + 2.0.5 ===== diff --git a/pygal/__init__.py b/pygal/__init__.py index 907ab90..d76d8e5 100644 --- a/pygal/__init__.py +++ b/pygal/__init__.py @@ -24,7 +24,7 @@ and the maps extensions namespace module. """ -__version__ = '2.0.5' +__version__ = '2.0.6' import pkg_resources import sys diff --git a/pygal/graph/graph.py b/pygal/graph/graph.py index c4104ed..a381a37 100644 --- a/pygal/graph/graph.py +++ b/pygal/graph/graph.py @@ -747,8 +747,14 @@ class Graph(PublicApi): ) def _compute_x_labels(self): + + def format_if_value(label): + if not is_str(label): + return self._x_format(label) + return label + self._x_labels = self.x_labels and list( - zip(map(self._x_format, self.x_labels), self._x_pos)) + zip(map(format_if_value, self.x_labels), self._x_pos)) def _compute_y_labels(self): y_pos = compute_scale(