Browse Source

Fix for python 3 too

pull/58/head
Florian Mounier 11 years ago
parent
commit
a88bbf7366
  1. 6
      pygal/graph/bar.py
  2. 2
      pygal/graph/graph.py
  3. 8
      pygal/graph/stackedbar.py
  4. 2
      pygal/graph/verticalpyramid.py

6
pygal/graph/bar.py

@ -106,12 +106,12 @@ class Bar(Graph):
def _compute_secondary(self): def _compute_secondary(self):
if self.secondary_series: if self.secondary_series:
y_pos = zip(*self._y_labels)[1] y_pos = list(zip(*self._y_labels))[1]
ymin = self._secondary_min ymin = self._secondary_min
ymax = self._secondary_max ymax = self._secondary_max
min_0_ratio = (self.zero - self._box.ymin) / self._box.height min_0_ratio = (self.zero - self._box.ymin) / self._box.height or 1
max_0_ratio = (self._box.ymax - self.zero) / self._box.height max_0_ratio = (self._box.ymax - self.zero) / self._box.height or 1
new_ymax = (self.zero - ymin) * (1 / min_0_ratio - 1) new_ymax = (self.zero - ymin) * (1 / min_0_ratio - 1)
new_ymin = -(ymax - self.zero) * (1 / max_0_ratio - 1) new_ymin = -(ymax - self.zero) * (1 / max_0_ratio - 1)

2
pygal/graph/graph.py

@ -463,7 +463,7 @@ class Graph(BaseGraph):
def _compute_secondary(self): def _compute_secondary(self):
# secondary y axis support # secondary y axis support
if self.secondary_series and self._y_labels: if self.secondary_series and self._y_labels:
y_pos = zip(*self._y_labels)[1] y_pos = list(zip(*self._y_labels))[1]
if self.include_x_axis: if self.include_x_axis:
ymin = min(self._secondary_min, 0) ymin = min(self._secondary_min, 0)
ymax = max(self._secondary_max, 0) ymax = max(self._secondary_max, 0)

8
pygal/graph/stackedbar.py

@ -85,10 +85,10 @@ class StackedBar(Bar):
# In case of pyramids # In case of pyramids
sum_ = lambda x: sum(x) if isinstance(x, tuple) else x sum_ = lambda x: sum(x) if isinstance(x, tuple) else x
self._secondary_min = negative_vals and min( self._secondary_min = (negative_vals and min(
sum_(min(negative_vals)), self.zero) sum_(min(negative_vals)), self.zero)) or self.zero
self._secondary_max = positive_vals and max( self._secondary_max = (positive_vals and max(
sum_(max(positive_vals)), self.zero) sum_(max(positive_vals)), self.zero)) or self.zero
def _bar(self, parent, x, y, index, i, zero, shift=False, secondary=False): def _bar(self, parent, x, y, index, i, zero, shift=False, secondary=False):
if secondary: if secondary:

2
pygal/graph/verticalpyramid.py

@ -54,7 +54,7 @@ class VerticalPyramid(StackedBar):
def _compute_secondary(self): def _compute_secondary(self):
# Need refactoring # Need refactoring
if self.secondary_series: if self.secondary_series:
y_pos = zip(*self._y_labels)[1] y_pos = list(zip(*self._y_labels))[1]
positive_vals, negative_vals = self._get_separated_values(True) positive_vals, negative_vals = self._get_separated_values(True)
positive_sum = map(sum, positive_vals) or [self.zero] positive_sum = map(sum, positive_vals) or [self.zero]
negative_sum = map(sum, negative_vals) or [self.zero] negative_sum = map(sum, negative_vals) or [self.zero]

Loading…
Cancel
Save