diff --git a/demo/moulinrouge/__init__.py b/demo/moulinrouge/__init__.py index 6bf99e2..929ccdc 100644 --- a/demo/moulinrouge/__init__.py +++ b/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, diff --git a/pygal/graph/line.py b/pygal/graph/line.py index 3f1d1d7..25eb916 100644 --- a/pygal/graph/line.py +++ b/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] diff --git a/pygal/graph/radar.py b/pygal/graph/radar.py index 159111f..9d93e4b 100644 --- a/pygal/graph/radar.py +++ b/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: diff --git a/pygal/view.py b/pygal/view.py index 1060370..5886891 100644 --- a/pygal/view.py +++ b/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)))