diff --git a/CHANGELOG b/CHANGELOG index 929b64d..7fcb725 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ V 2.0.0 UNRELEASED Fix no data for graphs with only zeroes (#148) Support value formatter for pie graphs (#218) (thanks never-eat-yellow-snow) Add new Box plot modes and outliers and set extremes as default (#226 #121 #149) (thanks djezar) + Add secondary_range option to set range for secondary values. (#203) V 1.7.0 Remove DateY and replace it by real XY datetime, date, time and timedelta support. (#188) diff --git a/demo/moulinrouge/tests.py b/demo/moulinrouge/tests.py index 968cb1e..5cc365b 100644 --- a/demo/moulinrouge/tests.py +++ b/demo/moulinrouge/tests.py @@ -175,7 +175,7 @@ def get_test_routes(app): dot = Dot() dot.x_labels = map(str, range(4)) dot.add('a', [1, lnk(3, 'Foo'), 5, 3]) - dot.add('b', [2, 2, 0, 2]) + dot.add('b', [2, 2, 0, 2, .1]) dot.add('c', [5, 1, 5, lnk(3, 'Bar')]) dot.add('d', [5, 5, lnk(0, 'Babar'), 3]) @@ -582,6 +582,8 @@ def get_test_routes(app): chart = Line(title=u'Some different points', interpolate='cubic') chart.add('line', [1000, 2000, 7000]) chart.add('other line', [100, 500, 500], secondary=True) + chart.range = 0, 10000 + chart.secondary_range = 0, 1000 return chart.render_response() @app.route('/test/legend_at_bottom/') diff --git a/pygal/config.py b/pygal/config.py index 3e4122a..1405d9e 100644 --- a/pygal/config.py +++ b/pygal/config.py @@ -354,6 +354,11 @@ class Config(CommonConfig): None, list, "Value", "Explicitly specify min and max of values", "(ie: (0, 100))", int) + secondary_range = Key( + None, list, "Value", + "Explicitly specify min and max of secondary values", + "(ie: (0, 100))", int) + xrange = Key( None, list, "Value", "Explicitly specify min and max of x values " "(used in XY and Date charts)", diff --git a/pygal/graph/dot.py b/pygal/graph/dot.py index 8fb263f..87751ea 100644 --- a/pygal/graph/dot.py +++ b/pygal/graph/dot.py @@ -72,6 +72,7 @@ class Dot(Graph): def _plot(self): r_max = min( self.view.x(1) - self.view.x(0), - (self.view.y(0) or 0) - self.view.y(1)) / (2 * (self._max or 1) * 1.05) + (self.view.y(0) or 0) - self.view.y(1)) / ( + 2 * (self._max or 1) * 1.05) for serie in self.series: self.dot(serie, r_max) diff --git a/pygal/graph/graph.py b/pygal/graph/graph.py index 6e99ddf..808ea08 100644 --- a/pygal/graph/graph.py +++ b/pygal/graph/graph.py @@ -633,7 +633,8 @@ class Graph(BaseGraph): @cached_property def _secondary_min(self): """Getter for the minimum series value""" - return (self.range[0] if (self.range and self.range[0] is not None) + return (self.secondary_range[0] if ( + self.secondary_range and self.secondary_range[0] is not None) else (min(self._secondary_values) if self._secondary_values else None)) @@ -653,7 +654,8 @@ class Graph(BaseGraph): @cached_property def _secondary_max(self): """Getter for the maximum series value""" - return (self.range[1] if (self.range and self.range[1] is not None) + return (self.secondary_range[1] if ( + self.secondary_range and self.secondary_range[1] is not None) else (max(self._secondary_values) if self._secondary_values else None))