Browse Source

Fix metadata on radar by removing close hack

pull/8/head
Florian Mounier 13 years ago
parent
commit
d6514a1171
  1. 2
      demo/simple_test.py
  2. 6
      pygal/graph/line.py
  3. 7
      pygal/graph/radar.py

2
demo/simple_test.py

@ -161,7 +161,7 @@ config.fill = True
config.style = NeonStyle config.style = NeonStyle
config.x_labels = ( config.x_labels = (
'black', 'red', 'blue', 'yellow', 'orange', 'green', 'white') 'black', 'red', 'blue', 'yellow', 'orange', 'green', 'white')
config.interpolate = 'nearest' # config.interpolate = 'nearest'
radar = Radar(config) radar = Radar(config)
radar.add('test', [1, 4, lnk(10), 5, None, -2, 5]) radar.add('test', [1, 4, lnk(10), 5, None, -2, 5])
radar.add('test2', [10, 2, 0, 5, 1, 9, 4]) radar.add('test2', [10, 2, 0, 5, 1, 9, 4])

6
pygal/graph/line.py

@ -28,6 +28,10 @@ from pygal.util import cached_property, compute_scale, decorate
class Line(Graph): class Line(Graph):
"""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): def _get_value(self, values, i):
"""Get the value formatted for tooltip""" """Get the value formatted for tooltip"""
return self._format(values[i][1]) return self._format(values[i][1])
@ -87,7 +91,7 @@ class Line(Graph):
if self.fill: if self.fill:
view_values = self._fill(view_values) view_values = self._fill(view_values)
self.svg.line( 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 '')) class_='line reactive' + (' nofill' if not self.fill else ''))
def _compute(self): def _compute(self):

7
pygal/graph/radar.py

@ -108,11 +108,7 @@ class Radar(Line):
delta = 2 * pi / self._len delta = 2 * pi / self._len
x_pos = [.5 * pi + i * delta for i in range(self._len + 1)] x_pos = [.5 * pi + i * delta for i in range(self._len + 1)]
for serie in self.series: for serie in self.series:
vals = list(serie.values) vals = [val if val != None else 0 for val in 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]
serie.points = [ serie.points = [
(v, x_pos[i]) (v, x_pos[i])
for i, v in enumerate(vals)] for i, v in enumerate(vals)]
@ -139,3 +135,4 @@ class Radar(Line):
self._box.xmin = self._box.ymin = - self._box.ymax self._box.xmin = self._box.ymin = - self._box.ymax
self.x_pos = x_pos self.x_pos = x_pos
self._self_close = True

Loading…
Cancel
Save