Add a reverse option to the report tag helpers. - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 42019b02a0cf723dd20b78850cc68a7be2730fe1
(DIR) parent a634f6e205ca79484228ea21adbf3ad0176f05bb
(HTM) Author: Dieter Komendera <dieter@komendera.com>
Date: Wed, 1 Feb 2012 18:11:16 +0100
Add a reverse option to the report tag helpers.
Diffstat:
M lib/saulabs/reportable/report_tag_… | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
---
(DIR) diff --git a/lib/saulabs/reportable/report_tag_helper.rb b/lib/saulabs/reportable/report_tag_helper.rb
@@ -37,7 +37,8 @@ module Saulabs
#
def google_report_tag(data, options = {})
options.reverse_merge!(Config.google_options)
- data = data.to_a.collect { |d| d[1] }
+ data = options[:reverse] ? data.to_a.reverse : data.to_a
+ data = data.collect { |d| d[1] }
labels = ''
unless options[:labels].empty?
chxr = {}
@@ -88,13 +89,14 @@ module Saulabs
options.reverse_merge!(Config.raphael_options.slice(:width, :height, :format))
options.reverse_merge!(:dom_id => default_dom_id)
raphael_options.reverse_merge!(Config.raphael_options.except(:width, :height, :format))
+ data = options[:reverse] ? data.to_a.reverse : data.to_a
%Q{<div id="#{options[:dom_id]}" style="width:#{options[:width]}px;height:#{options[:height]}px;"></div>
<script type="text\/javascript" charset="utf-8">
var graph = Raphael('#{options[:dom_id]}');
graph.g.linechart(
-10, 4, #{options[:width]}, #{options[:height]},
- #{(0..data.to_a.size).to_a.to_json},
- #{data.to_a.map { |d| d[1].send(:eval, options[:format]) }.to_json},
+ #{(0..data.size).to_a.to_json},
+ #{data.map { |d| d[1].send(:eval, options[:format]) }.to_json},
#{raphael_options.to_json}
).hover(function() {
this.disc = graph.g.disc(this.x, this.y, 3).attr({fill: "#{options[:hover_fill_color]}", stroke: '#{options[:hover_line_color]}' }).insertBefore(this);
@@ -143,10 +145,11 @@ module Saulabs
options.reverse_merge!(Config.flot_options.slice(:width, :height, :format))
options.reverse_merge!(:dom_id => default_dom_id)
flot_options.reverse_merge!(Config.flot_options.except(:width, :height, :format))
+ data = options[:reverse] ? data.to_a.reverse : data.to_a
%Q{<div id="#{options[:dom_id]}" style="width:#{options[:width]}px;height:#{options[:height]}px;"></div>
<script type="text\/javascript" charset="utf-8">
$(function() {
- var set = #{data.to_a.map{|d| d[1] }.to_json},
+ var set = #{data.map{|d| d[1] }.to_json},
data = [];
for (var i = 0; i < set.length; i++) {
data.push([i, set[i]]);