rename SparklineTagHelper to ReportTahHelper - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 8a273651bcfc2cf9b02681e4988bcf0f1c4654a0
(DIR) parent 278f65e1bdf79c0e43c8a68ac48086e4d934b056
(HTM) Author: Marco Otte-Witte <marco.otte-witte@simplabs.com>
Date: Sun, 18 Apr 2010 17:56:41 +0200
rename SparklineTagHelper to ReportTahHelper
Diffstat:
D lib/saulabs/reportable/sparkline_t… | 62 -------------------------------
M rails/init.rb | 2 +-
M spec/other/sparkline_tag_helper_sp… | 4 ++--
3 files changed, 3 insertions(+), 65 deletions(-)
---
(DIR) diff --git a/lib/saulabs/reportable/sparkline_tag_helper.rb b/lib/saulabs/reportable/sparkline_tag_helper.rb
@@ -1,62 +0,0 @@
-module Saulabs
-
- module Reportable
-
- module SparklineTagHelper
-
- # Renders a sparkline with the given data.
- #
- # @param [Array<Array<DateTime, Float>>] data
- # an array of report data as returned by {Saulabs::Reportable::Report#run}
- # @param [Hash] options
- # options for the sparkline
- #
- # @option options [Fixnum] :width (300)
- # the width of the generated image
- # @option options [Fixnum] :height (34)
- # the height of the generated image
- # @option options [String] :line_color ('0077cc')
- # the line color of the generated image
- # @option options [String] :fill_color ('e6f2fa')
- # the fill color of the generated image
- # @option options [Array<Symbol>] :labels ([])
- # the axes to render lables for (Array of +:x+, +:y+, +:r+, +:t+; this is x axis, y axis, right, top)
- # @option options [String] :alt ('')
- # the alt attribute for the generated image
- # @option options [String] :title ('')
- # the title attribute for the generated image
- #
- # @return [String]
- # an image tag showing a sparkline for the passed +data+
- #
- # @example Rendering a sparkline tag for report data
- #
- # <%= sparkline_tag(User.registrations_report, :width => 200, :height => 100, :color => '000') %>
- #
- 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 = ''
- unless options[:labels].empty?
- chxr = {}
- options[:labels].each_with_index do |l, i|
- chxr[l] = "#{i}," + ([:x, :t].include?(l) ? "0,#{data.length}" : "#{[data.min, 0].min},#{data.max}")
- 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}#{title}",
- :alt => options[:alt],
- :title => options[:title]
- )
- end
-
- end
-
- end
-
-end
(DIR) diff --git a/rails/init.rb b/rails/init.rb
@@ -5,5 +5,5 @@ ActiveRecord::Base.class_eval do
end
ActionView::Base.class_eval do
- include Saulabs::Reportable::SparklineTagHelper
+ include Saulabs::Reportable::SparklineReportTagHelper
end
(DIR) diff --git a/spec/other/sparkline_tag_helper_spec.rb b/spec/other/sparkline_tag_helper_spec.rb
@@ -1,6 +1,6 @@
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
-describe Saulabs::Reportable::SparklineTagHelper do
+describe Saulabs::Reportable::ReportTagHelper do
before do
@helper = TestHelper.new
@@ -59,6 +59,6 @@ end
class TestHelper
- include Saulabs::Reportable::SparklineTagHelper
+ include Saulabs::Reportable::ReportTagHelper
end