0001-dataviz-handle-empty-percentage-value-38847.patch
combo/apps/dataviz/models.py | ||
---|---|---|
290 | 290 |
return force_text(value) |
291 | 291 |
chart.config.value_formatter = format_duration |
292 | 292 |
elif response.get('measure') == 'percent': |
293 |
percent_formatter = lambda x: '{:.1f}%'.format(x) |
|
293 |
percent_formatter = lambda x: '0%' if x is None else '{:.1f}%'.format(x)
|
|
294 | 294 |
chart.config.value_formatter = percent_formatter |
295 | 295 | |
296 | 296 |
return chart |
tests/test_dataviz.py | ||
---|---|---|
220 | 220 |
if url.path == '/visualization/10/json/': |
221 | 221 |
response = { |
222 | 222 |
'format': '1', |
223 |
'data': [10, 20, 30, 40], |
|
223 |
'data': [10, 20, 30, 40, None],
|
|
224 | 224 |
'axis': { |
225 | 225 |
'y_labels': ['web', 'mail', 'email', 'fax'] |
226 | 226 |
}, |
... | ... | |
422 | 422 |
resp = app.get('/api/dataviz/graph/1/') # get data in cache |
423 | 423 |
resp = app.get('/') |
424 | 424 |
assert '<td>10.0%</td>' in resp.text |
425 |
assert '<td>0%</td>' in resp.text |
|
425 | 426 | |
426 | 427 |
cell.chart_type = 'bar' |
427 | 428 |
cell.save() |
428 |
- |