Permalink
Browse files

Support :min and :max options to set graph scale.

  • Loading branch information...
1 parent 06849a2 commit aacda2612fb20a32f23323f9b49bb598e06e7fca @jloveces jloveces committed Feb 16, 2009
Showing with 6 additions and 3 deletions.
  1. +1 −0 History.txt
  2. +5 −3 lib/sparklines.rb
View
@@ -3,6 +3,7 @@
* Support disabling last point when label is shown [Justin Love]
* Handle missing data (nil) values in area, bar, discrete, smooth [Justin Love]
* Extract method: normalize [Justin Love]
+* Support :min and :max options to set graph scale [Justin Love]
== 0.5.2
View
@@ -104,6 +104,8 @@ def plot_to_image(data=[], options={})
:last_color => 'red',
:std_dev_color => '#efefef',
+ :min => nil,
+ :max => nil,
:has_min => false,
:has_max => false,
:has_last => nil,
@@ -630,12 +632,12 @@ def plot_error(options={})
def normalize_data
case @options[:type].to_s
when 'bar'
- @minimum_value = 0.0
+ @minimum_value = @options[:min] || 0.0
else
- @minimum_value = @data.compact.min
+ @minimum_value = @options[:min] || @data.compact.min
end
- @maximum_value = @data.compact.max
+ @maximum_value = @options[:max] || @data.compact.max
case @options[:type].to_s
when 'pie'

0 comments on commit aacda26

Please sign in to comment.