Browse Source

Prevent exceptions on empty logarithmic graphs

pull/26/head
Arjen Stolk 12 years ago
parent
commit
1101bb886d
  1. 5
      pygal/graph/base.py
  2. 1
      pygal/graph/graph.py
  3. 4
      pygal/view.py

5
pygal/graph/base.py

@ -52,9 +52,10 @@ class BaseGraph(object):
self.view = None
if self.logarithmic and self.zero == 0:
# Explicit min to avoid interpolation dependency
self.zero = min(filter(
positive_values = filter(
lambda x: x > 0,
[val for serie in self.series for val in serie.safe_values]))
[val for serie in self.series for val in serie.safe_values])
self.zero = min(positive_values) if positive_values else 0
self._draw()
self.svg.pre_render()

1
pygal/graph/graph.py

@ -198,6 +198,7 @@ class Graph(BaseGraph):
))
x = -5
y = self.view.y(position)
if not y: continue
if draw_axes:
self.svg.node(
guides, 'path',

4
pygal/view.py

@ -293,8 +293,8 @@ class LogView(View):
self.width = width
self.height = height
self.box = box
self.log10_ymax = log10(self.box.ymax)
self.log10_ymin = log10(self.box.ymin)
self.log10_ymax = log10(self.box.ymax) if self.box.ymax > 0 else 0
self.log10_ymin = log10(self.box.ymin) if self.box.ymin > 0 else 0
self.box.fix(False)
# pylint: enable-msg=W0231

Loading…
Cancel
Save