| rename SparklineTagHelper to ReportTahHelper - reportable - Fork of reportable … | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit 8a273651bcfc2cf9b02681e4988bcf0f1c4654a0 | |
| parent 278f65e1bdf79c0e43c8a68ac48086e4d934b056 | |
| Author: Marco Otte-Witte <[email protected]> | |
| 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(-) | |
| --- | |
| diff --git a/lib/saulabs/reportable/sparkline_tag_helper.rb b/lib/saulabs/repor… | |
| @@ -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#… | |
| - # @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… | |
| - # @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 … | |
| - # | |
| - def sparkline_tag(data, options = {}) | |
| - options.reverse_merge!({ :width => 300, :height => 34, :line_color => … | |
| - 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}" : "… | |
| - end | |
| - labels = "&chxt=#{options[:labels].map(&:to_s).join(',')}&chxr=#{opt… | |
| - 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#{… | |
| - :alt => options[:alt], | |
| - :title => options[:title] | |
| - ) | |
| - end | |
| - | |
| - end | |
| - | |
| - end | |
| - | |
| -end | |
| 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 | |
| diff --git a/spec/other/sparkline_tag_helper_spec.rb b/spec/other/sparkline_tag… | |
| @@ -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 |