From bdcc0ed9e838becff2f551411dab8245fa7add35 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Mon, 2 Nov 2015 15:46:23 +0100 Subject: [PATCH] Fix labels rotation > 180 (Fix #257) Fix secondary axis --- demo/moulinrouge/__init__.py | 18 +++++++------ demo/moulinrouge/tests.py | 21 +++++++++++++++- docs/changelog.rst | 3 ++- pygal/css/graph.css | 13 ++++++++++ pygal/graph/bar.py | 25 ------------------ pygal/graph/base.py | 6 +++++ pygal/graph/graph.py | 49 +++++++++++++++++++++++++++++------- 7 files changed, 92 insertions(+), 43 deletions(-) diff --git a/demo/moulinrouge/__init__.py b/demo/moulinrouge/__init__.py index 635aa92..2c96f9c 100644 --- a/demo/moulinrouge/__init__.py +++ b/demo/moulinrouge/__init__.py @@ -76,7 +76,7 @@ def create_app(): def _random_series(type, data, order): max = 10 ** order min = 10 ** random.randrange(0, order) - + with_2nd = bool(random.randint(0, 1)) series = [] for i in range(random.randrange(1, 10)): if type == 'Pie': @@ -89,7 +89,10 @@ def create_app(): else: values = [random_value((-max, min)[random.randrange(1, 2)], max) for i in range(data)] - series.append((random_label(), values)) + is_2nd = False + if with_2nd: + is_2nd = bool(random.randint(0, 1)) + series.append((random_label(), values, is_2nd)) return series from .tests import get_test_routes @@ -107,15 +110,15 @@ def create_app(): def svg(type, series, config): graph = get(type)( pickle.loads(b64decode(str(config)))) - for title, values in pickle.loads(b64decode(str(series))): - graph.add(title, values) + for title, values, is_2nd in pickle.loads(b64decode(str(series))): + graph.add(title, values, secondary=is_2nd) return graph.render_response() @app.route("/table///") def table(type, series, config): graph = get(type)(pickle.loads(b64decode(str(config)))) - for title, values in pickle.loads(b64decode(str(series))): - graph.add(title, values) + for title, values, is_2nd in pickle.loads(b64decode(str(series))): + graph.add(title, values, secondary=is_2nd) return graph.render_table() @app.route("/sparkline/