From d6514a11711f2d5b7e68d4345d4af9e73184c450 Mon Sep 17 00:00:00 2001 From: Florian Mounier Date: Mon, 16 Apr 2012 10:54:16 +0200 Subject: [PATCH] Fix metadata on radar by removing close hack --- demo/simple_test.py | 2 +- pygal/graph/line.py | 6 +++++- pygal/graph/radar.py | 7 ++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/demo/simple_test.py b/demo/simple_test.py index cc3a5fc..a1f320e 100755 --- a/demo/simple_test.py +++ b/demo/simple_test.py @@ -161,7 +161,7 @@ config.fill = True config.style = NeonStyle config.x_labels = ( 'black', 'red', 'blue', 'yellow', 'orange', 'green', 'white') -config.interpolate = 'nearest' +# config.interpolate = 'nearest' radar = Radar(config) radar.add('test', [1, 4, lnk(10), 5, None, -2, 5]) radar.add('test2', [10, 2, 0, 5, 1, 9, 4]) diff --git a/pygal/graph/line.py b/pygal/graph/line.py index afc0ae2..437b96d 100644 --- a/pygal/graph/line.py +++ b/pygal/graph/line.py @@ -28,6 +28,10 @@ from pygal.util import cached_property, compute_scale, decorate class Line(Graph): """Line graph""" + def __init__(self, *args, **kwargs): + self._self_close = False + super(Line, self).__init__(*args, **kwargs) + def _get_value(self, values, i): """Get the value formatted for tooltip""" return self._format(values[i][1]) @@ -87,7 +91,7 @@ class Line(Graph): if self.fill: view_values = self._fill(view_values) self.svg.line( - serie_node['plot'], view_values, + serie_node['plot'], view_values, close=self._self_close, class_='line reactive' + (' nofill' if not self.fill else '')) def _compute(self): diff --git a/pygal/graph/radar.py b/pygal/graph/radar.py index 5c8494b..09901de 100644 --- a/pygal/graph/radar.py +++ b/pygal/graph/radar.py @@ -108,11 +108,7 @@ class Radar(Line): delta = 2 * pi / self._len x_pos = [.5 * pi + i * delta for i in range(self._len + 1)] for serie in self.series: - vals = list(serie.values) - # TODO: Fix metadata add here - # vals.append(vals[0]) - # serie.metadata.append(serie.metadata[0]) - vals = [val if val != None else 0 for val in vals] + vals = [val if val != None else 0 for val in serie.values] serie.points = [ (v, x_pos[i]) for i, v in enumerate(vals)] @@ -139,3 +135,4 @@ class Radar(Line): self._box.xmin = self._box.ymin = - self._box.ymax self.x_pos = x_pos + self._self_close = True