Permalink
Browse files

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

  • Loading branch information...
1 parent 8f5ecec commit cbe70dd899bab374dfb02a5b325dd8a979adf441 @paradoxxxzero paradoxxxzero committed Sep 28, 2012
Showing with 15 additions and 6 deletions.
  1. +7 −1 demo/moulinrouge/tests.py
  2. +1 −1 pygal/css/graph.css
  3. +4 −3 pygal/graph/gauge.py
  4. +2 −0 pygal/test/test_graph.py
  5. +1 −1 pygal/util.py
View
8 demo/moulinrouge/tests.py
@@ -25,7 +25,7 @@ def test_unsorted():
@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 test_interpolate_for(chart):
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()
View
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 {
View
7 pygal/graph/gauge.py
@@ -50,7 +50,7 @@ def arc_pos(self, value):
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 @@ def _x_axis(self, draw_axes=True):
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',
View
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()
View
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

0 comments on commit cbe70dd

Please sign in to comment.