Browse Source

Add zero in config

pull/8/head
Florian Mounier 13 years ago
parent
commit
51150bd8d2
  1. 1
      pygal/config.py
  2. 4
      pygal/graph/bar.py
  3. 2
      pygal/graph/line.py

1
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"""

4
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

2
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)])

Loading…
Cancel
Save