From e36adf2ecff14ac94fa2c68e186e0f712b56288d Mon Sep 17 00:00:00 2001 From: chartique Date: Sat, 23 Jan 2016 09:38:20 -0500 Subject: [PATCH] Fixed so that Range works for charts. --- pygal/graph/graph.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pygal/graph/graph.py b/pygal/graph/graph.py index 38096fa..3d160a3 100644 --- a/pygal/graph/graph.py +++ b/pygal/graph/graph.py @@ -32,7 +32,7 @@ from pygal.util import ( cached_property, compute_scale, cut, decorate, get_text_box, get_texts_box, humanize, majorize, rad, reverse_text_len, split_title, truncate) -from pygal.view import LogView, ReverseView, View, XYLogView +from pygal.view import LogView, ReverseView, View, XYLogView, Box class Graph(PublicApi): @@ -71,6 +71,10 @@ class Graph(PublicApi): self.height - self.margin_box.y, self._box) + if self.range is not None: + self._box.ymax = self._max*(1+1/self.style.label_font_size/self._max) + self._box.ymin = self._min + def _make_graph(self): """Init common graph svg structure""" self.nodes['graph'] = self.svg.node( @@ -806,8 +810,11 @@ class Graph(PublicApi): map(self._x_label_format_if_value, self.x_labels_major)) or [] def _compute_y_labels(self): - y_pos = compute_scale( + print( self._box.ymin, self._box.ymax, self.logarithmic, + self.order_min, self.min_scale, self.max_scale) + y_pos = compute_scale( + self._min, self._max, self.logarithmic, self.order_min, self.min_scale, self.max_scale ) if self.y_labels: