Skip to content
This repository has been archived by the owner on Nov 25, 2017. It is now read-only.

Commit

Permalink
Remove division by zero error when data is all zeroes
Browse files Browse the repository at this point in the history
  • Loading branch information
arsatiki committed Feb 12, 2010
1 parent bbd8238 commit e477b52
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion googlecharts/templatetags/charts.py
Expand Up @@ -868,7 +868,9 @@ def num2chars(n, value_range):

def norm(n, value_range):
minvalue, maxvalue = value_range
if minvalue >= 0:
if minvalue == maxvalue:
return 0
elif minvalue >= 0:
return int(round(float(n) / maxvalue * 4095, 0))
elif maxvalue <= 0:
return 4095 - int(round(float(n) * 4095 / minvalue))
Expand Down

0 comments on commit e477b52

Please sign in to comment.