Permalink
Browse files

Fix problem with constant data causing divide by zero

Signed-off-by: Geoffrey Grosenbach <boss@topfunky.com>
  • Loading branch information...
1 parent 7945408 commit dc230e8579208c3d245bbfe4ddda1100965906a8 @kim-toms kim-toms committed with Jun 10, 2009
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/sparklines.rb
View
@@ -854,7 +854,8 @@ def normalize(x)
if x.nil?
nil
else
- (x.to_f - @minimum_value) * 100 / (@maximum_value - @minimum_value)
+ @minimum_value == @maximum_value ? @maximum_value :
+ (x.to_f - @minimum_value) * 100 / (@maximum_value - @minimum_value)
end
end

0 comments on commit dc230e8

Please sign in to comment.