add a default :format again and insert a default :dom_id - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 5ef77ac9f838a14326d882124c57fca5886be26b
(DIR) parent 85c95b60d0ebdfdbc145fc5eeb1f9d09130b5627
(HTM) Author: Marco Otte-Witte <marco.otte-witte@simplabs.com>
Date: Wed, 21 Apr 2010 16:07:53 +0200
add a default :format again and insert a default :dom_id
Diffstat:
M lib/saulabs/reportable/config.rb | 47 ++++++++++++++++++++++++++++++-
M lib/saulabs/reportable/report_cach… | 3 ++-
M lib/saulabs/reportable/report_tag_… | 33 ++++---------------------------
3 files changed, 52 insertions(+), 31 deletions(-)
---
(DIR) diff --git a/lib/saulabs/reportable/config.rb b/lib/saulabs/reportable/config.rb
@@ -1,3 +1,48 @@
-module Config
+module Saulabs
+
+ module Reportable
+
+ module Config
+
+ mattr_accessor :google_options
+
+ @@google_options = {
+ :width => 300,
+ :height => 34,
+ :line_color => '0077cc',
+ :fill_color => 'e6f2fa',
+ :labels => []
+ }
+
+ mattr_accessor :grafico_options
+
+ @@grafico_basic_options = {
+ :width => 300,
+ :height => 100,
+ :dom_id => nil,
+ :format => 'div(100).to_i',
+ :area_opacity => 0.3,
+ :markers => 'value',
+ :grid => false,
+ :draw_axis => false,
+ :plot_padding => 0,
+ :padding_left => 0,
+ :padding_bottom => 0,
+ :padding_right => 0,
+ :padding_top => 0,
+ :stroke_width => 2,
+ :show_vertical_labels => false,
+ :show_horizontal_labels => false,
+ :hover_color => '#000',
+ :hover_text_color => '#fff',
+ :vertical_label_unit => '',
+ :colors => { :data => '#2f69bf' },
+ :curve_amount => 1,
+ :focus_hint => false
+ }
+
+ end
+
+ end
end
(DIR) diff --git a/lib/saulabs/reportable/report_cache.rb b/lib/saulabs/reportable/report_cache.rb
@@ -1,4 +1,5 @@
require 'saulabs/reportable/reporting_period'
+require 'saulabs/reportable/result_set'
module Saulabs
@@ -93,7 +94,7 @@ module Saulabs
if options[:live_data]
result << [current_reporting_period.date_time, find_value(new_data, current_reporting_period)]
end
- result
+ Saulabs::Reportable::ResultSet.new(result, report.klass.name, report.name)
end
def self.find_value(data, reporting_period)
(DIR) diff --git a/lib/saulabs/reportable/report_tag_helper.rb b/lib/saulabs/reportable/report_tag_helper.rb
@@ -83,35 +83,10 @@ module Saulabs
# <%= report_tag(User.registrations_report, {:width => 200, :height => 100, :format => "div(100).to_i"}, {:vertical_label_unit => "registrations"}) %>
#
def grafico_report_tag(data, options = {}, grafico_options = {})
- options.reverse_merge!(
- {
- :width => 300,
- :height => 100,
- :dom_id => "reportable_#{Time.now.to_i}",
- :format => 'to_i'
- })
- grafico_options.reverse_merge!(
- {
- :area_opacity => 0.3,
- :markers => 'value',
- :grid => false,
- :draw_axis => false,
- :plot_padding => 0,
- :padding_left =>0,
- :padding_bottom => 0,
- :padding_right => 0,
- :padding_top => 0,
- :stroke_width => 2,
- :show_vertical_labels => false,
- :show_horizontal_labels => false,
- :hover_color => '#000',
- :hover_text_color => '#fff',
- :vertical_label_unit => '',
- :colors => { :data => '#2F69BF' },
- :curve_amount => 1,
- :focus_hint => false
- })
- %Q{<div id="#{options[:dom_id]}" style="width:#{options[:width]}px;height:#{options[:height]}px;"></div>
+ options.reverse_merge!(Config.grafico_options.slice(:width, :height))
+ options.reverse_merge!(:dom_id => "#{data.model_name.downcase}_#{data.report_name}")
+ grafico_options.reverse_merge!(Config.grafico_options.except(:width, :height))
+ %Q{<div id="#{options[:dom_id] || "reportable_#{Time.now}"}" style="width: #{options[:width]}px; height: #{options[:height]}px;"></div>
<script type="text/javascript" charset="utf-8">
new Grafico.AreaGraph(
$('#{options[:dom_id]}'),