Browse Source

Fix stacked lines

pull/8/head
Florian Mounier 13 years ago
parent
commit
f72e2a7446
  1. 4
      pygal/graph/base.py
  2. 11
      pygal/graph/line.py
  3. 5
      pygal/graph/stackedline.py
  4. 8
      pygal/style.py

4
pygal/graph/base.py

@ -177,6 +177,10 @@ class BaseGraph(object):
diff = self._len - len(serie.values)
serie.metadata += diff * [self.__value__(0)]
for metadata in serie.metadata:
if metadata.value == None:
metadata.value = 0
def _render(self):
"""Make the graph internally"""
self.reinit()

11
pygal/graph/line.py

@ -99,11 +99,12 @@ class Line(Graph):
] if self._len != 1 else [.5] # Center if only one value
for serie in self.series:
serie.points = [
(x_pos[i], v)
for i, v in enumerate(serie.values)]
if self.interpolate:
serie.interpolated = self._interpolate(serie.values, x_pos)
if not hasattr(serie, 'points'):
serie.points = [
(x_pos[i], v)
for i, v in enumerate(serie.values)]
if self.interpolate:
serie.interpolated = self._interpolate(serie.values, x_pos)
if self.include_x_axis:
self._box.ymin = min(self._min, 0)

5
pygal/graph/stackedline.py

@ -46,10 +46,7 @@ class StackedLine(Line):
] if self._len != 1 else [.5] # Center if only one value
accumulation = [0] * self._len
for serie in self.series:
accumulation = map(sum, izip_longest(
accumulation, [val
if val != None else 0
for val in serie.values], fillvalue=0))
accumulation = map(sum, zip(accumulation, serie.values))
serie.points = [
(x_pos[i], v)
for i, v in enumerate(accumulation)]

8
pygal/style.py

@ -34,10 +34,10 @@ class Style(object):
opacity_hover='.9',
transition='250ms',
colors=(
'#ff5995', '#b6e354', '#feed6c', '#8cedff', '#9e6ffe',
'#899ca1', '#f8f8f2', '#808384', '#bf4646', '#516083',
'#f92672', '#82b414', '#fd971f', '#56c2d6', '#8c54fe',
'#465457')):
'#ff5995', '#b6e354', '#feed6c', '#8cedff', '#9e6ffe',
'#899ca1', '#f8f8f2', '#bf4646', '#516083', '#f92672',
'#82b414', '#fd971f', '#56c2d6', '#808384', '#8c54fe',
'#465457')):
self.background = background
self.plot_background = plot_background
self.foreground = foreground

Loading…
Cancel
Save