From 51150bd8d264e3a812e799f72012718d4a7ff57c Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Mon, 20 Feb 2012 11:52:46 +0100 Subject: [PATCH] Add zero in config --- pygal/config.py | 1 + pygal/graph/bar.py | 4 ++-- pygal/graph/line.py | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pygal/config.py b/pygal/config.py index d656983..4c54ded 100644 --- a/pygal/config.py +++ b/pygal/config.py @@ -73,6 +73,7 @@ class Config(object): interpolate = None # Number of interpolated points between two values interpolation_precision = 250 + zero = 0 def __init__(self, **kwargs): """Can be instanciated with config kwargs""" diff --git a/pygal/graph/bar.py b/pygal/graph/bar.py index 87e57c8..ec09c31 100644 --- a/pygal/graph/bar.py +++ b/pygal/graph/bar.py @@ -84,8 +84,8 @@ class Bar(Graph): return stack_vals def _compute(self): - self._box.ymin = min(min(self._values), 0) - self._box.ymax = max(max(self._values), 0) + self._box.ymin = min(min(self._values), self.zero) + self._box.ymax = max(max(self._values), self.zero) x_step = len(self.series[0].values) x_pos = [x / float(x_step) for x in range(x_step + 1) ] if x_step > 1 else [0, 1] # Center if only one value diff --git a/pygal/graph/line.py b/pygal/graph/line.py index 8c597a8..3210c99 100644 --- a/pygal/graph/line.py +++ b/pygal/graph/line.py @@ -37,7 +37,7 @@ class Line(Graph): for val in serie.points] def _fill(self, values): - zero = self.view.y(min(max(0, self._box.ymin), self._box.ymax)) + zero = self.view.y(min(max(self.zero, self._box.ymin), self._box.ymax)) return ([(values[0][0], zero)] + values + [(values[-1][0], zero)])