diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index 1d7efb3..0601400 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -50,7 +50,7 @@ def get_test_routes(app): def test_bar_links(): bar = StackedLine(style=styles['default']( font_family='googlefont:Raleway')) - bar.js = ('http://l:2343/2.0.x/pygal-tooltips.js',) + # bar.js = ('http://l:2343/2.0.x/pygal-tooltips.js',) bar.title = 'Wow ! Such Chart !' bar.x_title = 'Many x labels' bar.y_title = 'Much y labels' @@ -142,6 +142,7 @@ def get_test_routes(app): def test_bar_none(): bar = Bar() bar.add('Lol', [2, None, 12]) + bar.x_labels = range(1, 4) return bar.render_response() @app.route('/test/print_values') diff --git a/docs/changelog.rst b/docs/changelog.rst index 623aaf5..7884c04 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -6,6 +6,7 @@ Changelog ================ * Fix the missing title on x_labels with labels. +* Auto cast to str x labels in non dual charts (#178) 2.0.0 ===== diff --git a/pygal/graph/funnel.py b/pygal/graph/funnel.py index 82f4074..f76c1fa 100644 --- a/pygal/graph/funnel.py +++ b/pygal/graph/funnel.py @@ -23,6 +23,7 @@ from __future__ import division from pygal.adapters import none_to_zero, positive from pygal.graph.graph import Graph from pygal.util import alter, cut, decorate +from pygal._compat import to_str class Funnel(Graph): @@ -93,7 +94,8 @@ class Funnel(Graph): def _compute_x_labels(self): self._x_labels = list( - zip(self.x_labels or [ + zip(self.x_labels and + map(to_str, self.x_labels) or [ serie.title['title'] if isinstance(serie.title, dict) else serie.title for serie in self.series], diff --git a/pygal/graph/graph.py b/pygal/graph/graph.py index a8ba5e5..e786bb1 100644 --- a/pygal/graph/graph.py +++ b/pygal/graph/graph.py @@ -735,7 +735,7 @@ class Graph(PublicApi): def _compute_x_labels(self): self._x_labels = self.x_labels and list( - zip(self.x_labels, self._x_pos)) + zip(map(to_str, self.x_labels), self._x_pos)) def _compute_y_labels(self): y_pos = compute_scale(