Browse Source

Remove value from dict this fixes #4 and fix zero value in gauge

pull/8/head
Florian Mounier 12 years ago
parent
commit
cbe70dd899
  1. 8
      demo/moulinrouge/tests.py
  2. 2
      pygal/css/graph.css
  3. 7
      pygal/graph/gauge.py
  4. 2
      pygal/test/test_graph.py
  5. 2
      pygal/util.py

8
demo/moulinrouge/tests.py

@ -25,7 +25,7 @@ def get_test_routes(app):
@app.route('/test/bar_links')
def test_bar_links():
bar = Bar(style=styles['neon'])
bar = Gauge(style=styles['neon'])
bar.add('1234', [
{'value': 10,
'label': 'Ten',
@ -106,6 +106,12 @@ def get_test_routes(app):
graph.add('2', [7, -4, 10, None, 8, 3, 1])
return graph.render_response()
@app.route('/test/negative/<chart>')
def test_negative_for(chart):
graph = CHARTS_BY_NAME[chart](interpolate='cubic')
graph.add('1', [10, 0, -10])
return graph.render_response()
@app.route('/test/stacked')
def test_stacked():
stacked = StackedBar()

2
pygal/css/graph.css

@ -58,7 +58,7 @@ text.no_data {
stroke-dasharray: 4,4;
}
.axis .major.line {
.axis .major.guide.line {
stroke-dasharray: 6,6;
}
.axis text.major {

7
pygal/graph/gauge.py

@ -50,7 +50,7 @@ class Gauge(Graph):
def needle(self, serie_node, serie,):
thickness = .05
for i, value in enumerate(serie.values):
if not value:
if value is None:
continue
theta = self.arc_pos(value)
fmt = lambda x: '%f %f' % x
@ -90,8 +90,9 @@ class Gauge(Graph):
self.svg.line(
guides, [self.view((0, theta)), self.view((.95, theta))],
close=True,
class_='guide line %s' % ('major'
if i in (0, len(self._x_labels) - 1) else ''))
class_='guide line %s' % (
'major' if i in (0, len(self._x_labels) - 1)
else ''))
x, y = self.view((.9, theta))
self.svg.node(guides, 'text',

2
pygal/test/test_graph.py

@ -86,6 +86,8 @@ def test_metadata(Chart):
'Five', 'http://7.example.com/', 'Seven'):
assert md in cut(q('desc'), 'text')
assert len(v) == len(q('.tooltip-trigger').siblings('.value'))
def test_empty_lists(Chart):
chart = Chart()

2
pygal/util.py

@ -323,7 +323,7 @@ def prepare_values(raw, config, cls):
(width - len(raw_values)) * [None] # aligning values
if len(raw_values) < width else [])):
if isinstance(raw_value, dict):
value = dict(raw_value).pop('value')
value = raw_value.pop('value')
metadata[index] = raw_value
else:
value = raw_value

Loading…
Cancel
Save