Browse Source

And some bug fix

pull/8/head
Florian Mounier 13 years ago
parent
commit
dc8574503b
  1. 2
      demo/moulinrouge/__init__.py
  2. 7
      pygal/graph/line.py
  3. 4
      pygal/graph/radar.py
  4. 1
      pygal/view.py

2
demo/moulinrouge/__init__.py

@ -71,7 +71,7 @@ def create_app():
svgs = [url_for('all_svg', type=type, style=style)
for style in styles
for type in ('Bar', 'Line', 'XY', 'Pie', 'StackedBar',
'HorizontalBar', 'HorizontalStackedBar')]
'HorizontalBar', 'HorizontalStackedBar', 'Radar')]
return render_template('svgs.jinja2',
svgs=svgs,
width=width,

7
pygal/graph/line.py

@ -4,6 +4,10 @@ from pygal.graph.graph import Graph
class Line(Graph):
"""Line graph"""
def __init__(self, *args, **kwargs):
super(Line, self).__init__(*args, **kwargs)
self._line_close = False
def _get_value(self, values, i):
return str(values[i][1])
@ -16,7 +20,8 @@ class Line(Graph):
self.svg.node(dot, 'circle', cx=x, cy=y, r=2.5)
self.svg.node(dot, 'text', x=x, y=y
).text = self._get_value(values, i)
self.svg.line(serie_node, view_values, class_='line', close=True)
self.svg.line(
serie_node, view_values, class_='line', close=self._line_close)
def _compute(self):
vals = [val for serie in self.series for val in serie.values]

4
pygal/graph/radar.py

@ -7,6 +7,9 @@ from math import cos, sin, pi
class Radar(Line):
"""Kiviat graph"""
def _get_value(self, values, i):
return str(values[i][0])
def _set_view(self):
self.view = PolarView(
self.width - self.margin.x,
@ -72,6 +75,7 @@ class Radar(Line):
self._x_labels = self.x_labels and zip(self.x_labels, self._x_pos)
self._y_labels = zip(map(str, self._y_pos), self._y_pos)
self._box.xmin = self._box.ymin = - self._box.ymax
self._line_close = True
def _plot(self):
for serie in self.series:

1
pygal/view.py

@ -72,5 +72,6 @@ class View(object):
class PolarView(View):
def __call__(self, rtheta):
r, theta = rtheta
r = max(r, 0)
return super(PolarView, self).__call__(
(r * cos(theta), r * sin(theta)))

Loading…
Cancel
Save