* cleaned Readme * allow definition od title for the generated sparkline image - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit a0b40bc8924c92736fa148ff4625dccc2b4e8a6e
(DIR) parent 1fb6c00be0c30f0a4ce7c97035830c5506e5ffab
(HTM) Author: Marco Otte-Witte <marco.otte-witte@simplabs.com>
Date: Wed, 24 Feb 2010 19:39:35 +0100
* cleaned Readme
* allow definition od title for the generated sparkline image
Diffstat:
M HISTORY.rdoc | 32 +++----------------------------
M lib/saulabs/reportable/sparkline_t… | 10 +++++++---
M spec/other/sparkline_tag_helper_sp… | 18 ++++++++++++++++++
3 files changed, 28 insertions(+), 32 deletions(-)
---
(DIR) diff --git a/HISTORY.rdoc b/HISTORY.rdoc
@@ -1,29 +1,3 @@
-=== v1.3.2
+=== v1.0.0
-* the tag helper now support options for title and alt tags (thanks to jan (http://github.com/jan))
-* reports are now cached also when conditions are specified (thanks to eric (http://github.com/eric))
-
-=== v1.3.1
-
-* fixed migration template
-* fixed data type returned by the report methods
-
-=== v1.3
-
-* Fixed another bug where two report runs with different :end_date values would lead to invalid data
-* Entries in the report cache entry are no longer identified by the :limit the report was run with (YOU WILL HAVE TO RECREATE YOUR CACHE TABLE!)
-* rewrote the data retrieval and processing code, it's now much more compact and less complicated with fewer cache misses
-
-=== v1.2
-
-* FIXED: duplicate key error when using custom time zones (thanks to myronmarston (http://github.com/myronmarston))
-
-=== v1.1
-
-* new :end_date option: if specified, only data for the reporting periods for (end date - (limit - 1)) until (end date) will be included in the result set (thanks to myronmarston (http://github.com/myronmarston) for the great work)
-* added rcov report and spec report
-
-
-=== prior to v1.1
-
-* cannot remember, should habe started a history file right from the beginning...
-\ No newline at end of file
+* Initial release of the new Reportable gem (this was formerly ReportsAsSparkline)
+\ No newline at end of file
(DIR) diff --git a/lib/saulabs/reportable/sparkline_tag_helper.rb b/lib/saulabs/reportable/sparkline_tag_helper.rb
@@ -25,7 +25,7 @@ module Saulabs #:nodoc:
def sparkline_tag(data, options = {})
options.reverse_merge!({ :width => 300, :height => 34, :line_color => '0077cc', :fill_color => 'e6f2fa', :labels => [], :alt => '', :title => '' })
data = data.collect { |d| d[1] }
- labels = ""
+ labels = ''
unless options[:labels].empty?
chxr = {}
options[:labels].each_with_index do |l, i|
@@ -33,9 +33,13 @@ module Saulabs #:nodoc:
end
labels = "&chxt=#{options[:labels].map(&:to_s).join(',')}&chxr=#{options[:labels].collect{|l| chxr[l]}.join('|')}"
end
+ title = ''
+ unless options[:title].empty?
+ title = "&chtt=#{options[:title]}"
+ end
image_tag(
- "http://chart.apis.google.com/chart?cht=ls&chs=#{options[:width]}x#{options[:height]}&chd=t:#{data.join(',')}&chco=#{options[:line_color]}&chm=B,#{options[:fill_color]},0,0,0&chls=1,0,0&chds=#{data.min},#{data.max}#{labels}",
- :alt => options[:alt],
+ "http://chart.apis.google.com/chart?cht=ls&chs=#{options[:width]}x#{options[:height]}&chd=t:#{data.join(',')}&chco=#{options[:line_color]}&chm=B,#{options[:fill_color]},0,0,0&chls=1,0,0&chds=#{data.min},#{data.max}#{labels}#{title}",
+ :alt => options[:alt],
:title => options[:title]
)
end
(DIR) diff --git a/spec/other/sparkline_tag_helper_spec.rb b/spec/other/sparkline_tag_helper_spec.rb
@@ -35,6 +35,24 @@ describe Saulabs::Reportable::SparklineTagHelper do
@helper.sparkline_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTime.now, 3.0]], :line_color => '000000', :fill_color => 'ffffff')
end
+ it 'should set the parameters for a custom title if a title specified' do
+ @helper.should_receive(:image_tag).once.with(
+ 'http://chart.apis.google.com/chart?cht=ls&chs=300x34&chd=t:1.0,2.0,3.0&chco=0077cc&chm=B,e6f2fa,0,0,0&chls=1,0,0&chds=1.0,3.0&chtt=title',
+ { :title => 'title', :alt => '' }
+ )
+
+ @helper.sparkline_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTime.now, 3.0]], :title => 'title')
+ end
+
+ it 'should use a specified alt text as alt text for the image' do
+ @helper.should_receive(:image_tag).once.with(
+ 'http://chart.apis.google.com/chart?cht=ls&chs=300x34&chd=t:1.0,2.0,3.0&chco=0077cc&chm=B,e6f2fa,0,0,0&chls=1,0,0&chds=1.0,3.0',
+ { :title => '', :alt => 'alt' }
+ )
+
+ @helper.sparkline_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTime.now, 3.0]], :alt => 'alt')
+ end
+
end
end