renamed AssetTagHelper to SparklineTagHelper; updated docs - reportable - Fork of reportable required by WarVox, from hdm/reportable.
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 0e966f9804d9bdcbac85e1e0473b697fbb139c43
(DIR) parent 811195e44a63b61df0a806e8f53c927a42ea6751
(HTM) Author: Marco Otte-Witte <marco.otte-witte@simplabs.com>
Date: Thu, 15 Jan 2009 16:54:45 +0100
renamed AssetTagHelper to SparklineTagHelper; updated docs
Diffstat:
M README.rdoc | 8 ++++++++
M lib/kvlr/reports_as_sparkline/spar… | 14 ++++++++++----
D rdoc/classes/Kvlr/ReportsAsSparkli… | 172 ------------------------------
M rdoc/classes/Kvlr/ReportsAsSparkli… | 12 ++++++------
M rdoc/classes/Kvlr/ReportsAsSparkli… | 35 +++++++++++++++----------------
A rdoc/classes/Kvlr/ReportsAsSparkli… | 184 +++++++++++++++++++++++++++++++
M rdoc/created.rid | 2 +-
M rdoc/files/README_rdoc.html | 23 ++++++++++++++++++++++-
D rdoc/files/lib/kvlr/reports_as_spa… | 102 -------------------------------
M rdoc/files/lib/kvlr/reports_as_spa… | 2 +-
M rdoc/files/lib/kvlr/reports_as_spa… | 2 +-
A rdoc/files/lib/kvlr/reports_as_spa… | 102 +++++++++++++++++++++++++++++++
M rdoc/files/lib/kvlr/reports_as_spa… | 2 +-
M rdoc/fr_class_index.html | 2 +-
M rdoc/fr_file_index.html | 2 +-
M rdoc/fr_method_index.html | 6 +++---
M spec/other/sparkline_tag_helper_sp… | 18 +++++++++++++++++-
17 files changed, 375 insertions(+), 313 deletions(-)
---
(DIR) diff --git a/README.rdoc b/README.rdoc
@@ -46,6 +46,14 @@ You can than render sparklines for these reports with sparkline_tag in your view
<%= sparkline_tag(User.registrations_report) %>
+The +sparkline_tag+ helper takes the following parameters:
+
+* width - The width of the generated image
+* height - The height of the generated image
+* line_color - The line color of the sparkline (hex code)
+* fill_color - The color to fill the area below the sparkline with (hex code)
+* labes - The axes to render lables for (Array of :x, :y, :r, :t; this is x axis, y axis, right, top)
+
== Installation
Installation requires 3 simple steps:
(DIR) diff --git a/lib/kvlr/reports_as_sparkline/sparkline_tag_helper.rb b/lib/kvlr/reports_as_sparkline/sparkline_tag_helper.rb
@@ -14,15 +14,21 @@ module Kvlr #:nodoc:
#
# * <tt>width</tt> - The width of the generated image
# * <tt>height</tt> - The height of the generated image
- # * <tt>color</tt> - The base color of the generated image (hex code)
+ # * <tt>line_color</tt> - The line color of the sparkline (hex code)
+ # * <tt>fill_color</tt> - The color to fill the area below the sparkline with (hex code)
+ # * <tt>labes</tt> - The axes to render lables for (Array of :x, :y, :r, :t; this is x axis, y axis, right, top)
#
# ==== Example
# <%= sparkline_tag(User.registrations_report, :width => 200, :height => 100, :color => '000') %>
def sparkline_tag(data, options = {})
- options.reverse_merge!({:width => 300, :height => 34, :color => '0077cc'})
- data.collect! { |d| d[1] }
+ options.reverse_merge!({ :width => 300, :height => 34, :line_color => '0077cc', :fill_color => 'e6f2fa', :labels => [] })
+ data = data.collect { |d| d[1] }
+ labels = ""
+ unless options[:labels].empty?
+ labels = "&chxt=#{options[:labels].map(&:to_s).join(',')}&chxr=0,0,#{data.length}|1,0,#{data.max}|2,0,#{data.max}|3,0,#{data.length}"
+ end
image_tag(
- "http://chart.apis.google.com/chart?cht=ls&chs=#{options[:width]}x#{options[:height]}&chd=t:#{data.join(',')}&chco=#{options[:color]}&chm=B,E6F2FA,0,0,0&chls=1,0,0&chds=#{data.min},#{data.max}"
+ "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}"
)
end
(DIR) diff --git a/rdoc/classes/Kvlr/ReportsAsSparkline/AssetTagHelper.html b/rdoc/classes/Kvlr/ReportsAsSparkline/AssetTagHelper.html
@@ -1,171 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <title>Module: Kvlr::ReportsAsSparkline::AssetTagHelper</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
- <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
- <script type="text/javascript">
- // <![CDATA[
-
- function popupCode( url ) {
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
- }
-
- function toggleCode( id ) {
- if ( document.getElementById )
- elem = document.getElementById( id );
- else if ( document.all )
- elem = eval( "document.all." + id );
- else
- return false;
-
- elemStyle = elem.style;
-
- if ( elemStyle.display != "block" ) {
- elemStyle.display = "block"
- } else {
- elemStyle.display = "none"
- }
-
- return true;
- }
-
- // Make codeblocks hidden by default
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
-
- // ]]>
- </script>
-
-</head>
-<body>
-
-
-
- <div id="classHeader">
- <table class="header-table">
- <tr class="top-aligned-row">
- <td><strong>Module</strong></td>
- <td class="class-name-in-header">Kvlr::ReportsAsSparkline::AssetTagHelper</td>
- </tr>
- <tr class="top-aligned-row">
- <td><strong>In:</strong></td>
- <td>
- <a href="../../../files/lib/kvlr/reports_as_sparkline/asset_tag_helper_rb.html">
- lib/kvlr/reports_as_sparkline/asset_tag_helper.rb
- </a>
- <br />
- </td>
- </tr>
-
- </table>
- </div>
- <!-- banner header -->
-
- <div id="bodyContent">
-
-
-
- <div id="contextContent">
-
-
-
- </div>
-
- <div id="method-list">
- <h3 class="section-bar">Methods</h3>
-
- <div class="name-list">
- <a href="#M000002">sparkline_tag</a>
- </div>
- </div>
-
- </div>
-
-
- <!-- if includes -->
-
- <div id="section">
-
-
-
-
-
-
-
-
- <!-- if method_list -->
- <div id="methods">
- <h3 class="section-bar">Public Instance methods</h3>
-
- <div id="method-M000002" class="method-detail">
- <a name="M000002"></a>
-
- <div class="method-heading">
- <a href="#M000002" class="method-signature">
- <span class="method-name">sparkline_tag</span><span class="method-args">(data, options = {})</span>
- </a>
- </div>
-
- <div class="method-description">
- <p>
-Renders a sparkline with the given data.
-</p>
-<h4>Parameters</h4>
-<ul>
-<li><tt>data</tt> - The data to render the sparkline for
-
-</li>
-</ul>
-<h4>Options</h4>
-<ul>
-<li><tt>width</tt> - The width of the generated image
-
-</li>
-<li><tt>height</tt> - The height of the generated image
-
-</li>
-<li><tt>color</tt> - The base color of the generated image (hex code)
-
-</li>
-</ul>
-<h4>Example</h4>
-<p>
-<%= <a
-href="AssetTagHelper.html#M000002">sparkline_tag</a>(User.registrations_report,
-:width => 200, :height => 100, :color => ‘000’) %>
-</p>
- <p><a class="source-toggle" href="#"
- onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
- <div class="method-source-code" id="M000002-source">
-<pre>
- <span class="ruby-comment cmt"># File lib/kvlr/reports_as_sparkline/asset_tag_helper.rb, line 21</span>
-21: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sparkline_tag</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">options</span> = {})
-22: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>({<span class="ruby-identifier">:width</span> =<span class="ruby-operator">></span> <span class="ruby-value">300</span>, <span class="ruby-identifier">:height</span> =<span class="ruby-operator">></span> <span class="ruby-value">34</span>, <span class="ruby-identifier">:color</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'0077cc'</span>})
-23: <span class="ruby-identifier">data</span>.<span class="ruby-identifier">collect!</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-identifier">d</span>[<span class="ruby-value">1</span>] }
-24: <span class="ruby-identifier">image_tag</span>(
-25: <span class="ruby-node">"http://chart.apis.google.com/chart?cht=ls&chs=#{options[:width]}x#{options[:height]}&chd=t:#{data.join(',')}&chco=#{options[:color]}&chm=B,E6F2FA,0,0,0&chls=1,0,0&chds=#{data.min},#{data.max}"</span>
-26: )
-27: <span class="ruby-keyword kw">end</span>
-</pre>
- </div>
- </div>
- </div>
-
-
- </div>
-
-
- </div>
-
-
-<div id="validator-badges">
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
-</div>
-
-</body>
-</html>
-\ No newline at end of file
(DIR) diff --git a/rdoc/classes/Kvlr/ReportsAsSparkline/ClassMethods.html b/rdoc/classes/Kvlr/ReportsAsSparkline/ClassMethods.html
@@ -80,7 +80,7 @@
<h3 class="section-bar">Methods</h3>
<div class="name-list">
- <a href="#M000001">reports_as_sparkline</a>
+ <a href="#M000002">reports_as_sparkline</a>
</div>
</div>
@@ -102,11 +102,11 @@
<div id="methods">
<h3 class="section-bar">Public Instance methods</h3>
- <div id="method-M000001" class="method-detail">
- <a name="M000001"></a>
+ <div id="method-M000002" class="method-detail">
+ <a name="M000002"></a>
<div class="method-heading">
- <a href="#M000001" class="method-signature">
+ <a href="#M000002" class="method-signature">
<span class="method-name">reports_as_sparkline</span><span class="method-args">(name, options = {})</span>
</a>
</div>
@@ -164,8 +164,8 @@ records that match there conditions are reported on
end
</pre>
<p><a class="source-toggle" href="#"
- onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
- <div class="method-source-code" id="M000001-source">
+ onclick="toggleCode('M000002-source');return false;">[Source]</a></p>
+ <div class="method-source-code" id="M000002-source">
<pre>
<span class="ruby-comment cmt"># File lib/kvlr/reports_as_sparkline.rb, line 38</span>
38: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">reports_as_sparkline</span>(<span class="ruby-identifier">name</span>, <span class="ruby-identifier">options</span> = {})
(DIR) diff --git a/rdoc/classes/Kvlr/ReportsAsSparkline/Report.html b/rdoc/classes/Kvlr/ReportsAsSparkline/Report.html
@@ -168,12 +168,12 @@ and calculations
<ul>
<li><tt>klass</tt> - The model the report works on (This is the class you
invoke <a
-href="ClassMethods.html#M000001">Kvlr::ReportsAsSparkline::ClassMethods#reports_as_sparkline</a>
+href="ClassMethods.html#M000002">Kvlr::ReportsAsSparkline::ClassMethods#reports_as_sparkline</a>
on)
</li>
<li><tt>name</tt> - The name of the report (as in <a
-href="ClassMethods.html#M000001">Kvlr::ReportsAsSparkline::ClassMethods#reports_as_sparkline</a>)
+href="ClassMethods.html#M000002">Kvlr::ReportsAsSparkline::ClassMethods#reports_as_sparkline</a>)
</li>
</ul>
@@ -218,12 +218,11 @@ records that match there conditions are reported on
29: <span class="ruby-ivar">@options</span> = {
30: <span class="ruby-identifier">:limit</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:limit</span>] <span class="ruby-operator">||</span> <span class="ruby-value">100</span>,
31: <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:conditions</span>] <span class="ruby-operator">||</span> [],
-32: <span class="ruby-identifier">:grouping</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Grouping</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:grouping</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">:day</span>),
-33: <span class="ruby-identifier">:live_data</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:live_data</span>] <span class="ruby-operator">||</span> <span class="ruby-keyword kw">false</span>
-34: }
-35: <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">options</span>)
-36: <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">freeze</span>
-37: <span class="ruby-keyword kw">end</span>
+32: <span class="ruby-identifier">:grouping</span> =<span class="ruby-operator">></span> <span class="ruby-constant">Grouping</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:grouping</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">:day</span>)
+33: }
+34: <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">options</span>)
+35: <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">freeze</span>
+36: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
@@ -263,16 +262,16 @@ you specify conditions here, caching will be disabled</b>)
onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
<div class="method-source-code" id="M000010-source">
<pre>
- <span class="ruby-comment cmt"># File lib/kvlr/reports_as_sparkline/report.rb, line 45</span>
-45: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">options</span> = {})
-46: <span class="ruby-identifier">ensure_valid_options</span>(<span class="ruby-identifier">options</span>, <span class="ruby-identifier">:run</span>)
-47: <span class="ruby-identifier">custom_conditions</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">:conditions</span>)
-48: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-ivar">@options</span>)
-49: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:grouping</span>] = <span class="ruby-constant">Grouping</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:grouping</span>]) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:grouping</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Grouping</span>)
-50: <span class="ruby-constant">ReportCache</span>.<span class="ruby-identifier">process</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">options</span>, <span class="ruby-operator">!</span><span class="ruby-identifier">custom_conditions</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">begin_at</span><span class="ruby-operator">|</span>
-51: <span class="ruby-identifier">read_data</span>(<span class="ruby-identifier">begin_at</span>, <span class="ruby-identifier">options</span>)
-52: <span class="ruby-keyword kw">end</span>
-53: <span class="ruby-keyword kw">end</span>
+ <span class="ruby-comment cmt"># File lib/kvlr/reports_as_sparkline/report.rb, line 44</span>
+44: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">options</span> = {})
+45: <span class="ruby-identifier">ensure_valid_options</span>(<span class="ruby-identifier">options</span>, <span class="ruby-identifier">:run</span>)
+46: <span class="ruby-identifier">custom_conditions</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">:conditions</span>)
+47: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-ivar">@options</span>)
+48: <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:grouping</span>] = <span class="ruby-constant">Grouping</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:grouping</span>]) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:grouping</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Grouping</span>)
+49: <span class="ruby-constant">ReportCache</span>.<span class="ruby-identifier">process</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">options</span>, <span class="ruby-operator">!</span><span class="ruby-identifier">custom_conditions</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">begin_at</span><span class="ruby-operator">|</span>
+50: <span class="ruby-identifier">read_data</span>(<span class="ruby-identifier">begin_at</span>, <span class="ruby-identifier">options</span>)
+51: <span class="ruby-keyword kw">end</span>
+52: <span class="ruby-keyword kw">end</span>
</pre>
</div>
</div>
(DIR) diff --git a/rdoc/classes/Kvlr/ReportsAsSparkline/SparklineTagHelper.html b/rdoc/classes/Kvlr/ReportsAsSparkline/SparklineTagHelper.html
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Module: Kvlr::ReportsAsSparkline::SparklineTagHelper</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
+ <script type="text/javascript">
+ // <![CDATA[
+
+ function popupCode( url ) {
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
+ }
+
+ function toggleCode( id ) {
+ if ( document.getElementById )
+ elem = document.getElementById( id );
+ else if ( document.all )
+ elem = eval( "document.all." + id );
+ else
+ return false;
+
+ elemStyle = elem.style;
+
+ if ( elemStyle.display != "block" ) {
+ elemStyle.display = "block"
+ } else {
+ elemStyle.display = "none"
+ }
+
+ return true;
+ }
+
+ // Make codeblocks hidden by default
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
+
+ // ]]>
+ </script>
+
+</head>
+<body>
+
+
+
+ <div id="classHeader">
+ <table class="header-table">
+ <tr class="top-aligned-row">
+ <td><strong>Module</strong></td>
+ <td class="class-name-in-header">Kvlr::ReportsAsSparkline::SparklineTagHelper</td>
+ </tr>
+ <tr class="top-aligned-row">
+ <td><strong>In:</strong></td>
+ <td>
+ <a href="../../../files/lib/kvlr/reports_as_sparkline/sparkline_tag_helper_rb.html">
+ lib/kvlr/reports_as_sparkline/sparkline_tag_helper.rb
+ </a>
+ <br />
+ </td>
+ </tr>
+
+ </table>
+ </div>
+ <!-- banner header -->
+
+ <div id="bodyContent">
+
+
+
+ <div id="contextContent">
+
+
+
+ </div>
+
+ <div id="method-list">
+ <h3 class="section-bar">Methods</h3>
+
+ <div class="name-list">
+ <a href="#M000001">sparkline_tag</a>
+ </div>
+ </div>
+
+ </div>
+
+
+ <!-- if includes -->
+
+ <div id="section">
+
+
+
+
+
+
+
+
+ <!-- if method_list -->
+ <div id="methods">
+ <h3 class="section-bar">Public Instance methods</h3>
+
+ <div id="method-M000001" class="method-detail">
+ <a name="M000001"></a>
+
+ <div class="method-heading">
+ <a href="#M000001" class="method-signature">
+ <span class="method-name">sparkline_tag</span><span class="method-args">(data, options = {})</span>
+ </a>
+ </div>
+
+ <div class="method-description">
+ <p>
+Renders a sparkline with the given data.
+</p>
+<h4>Parameters</h4>
+<ul>
+<li><tt>data</tt> - The data to render the sparkline for
+
+</li>
+</ul>
+<h4>Options</h4>
+<ul>
+<li><tt>width</tt> - The width of the generated image
+
+</li>
+<li><tt>height</tt> - The height of the generated image
+
+</li>
+<li><tt>line_color</tt> - The line color of the sparkline (hex code)
+
+</li>
+<li><tt>fill_color</tt> - The color to fill the area below the sparkline with
+(hex code)
+
+</li>
+<li><tt>labes</tt> - The axes to render lables for (Array of :x, :y, :r, :t;
+this is x axis, y axis, right, top)
+
+</li>
+</ul>
+<h4>Example</h4>
+<p>
+<%= <a
+href="SparklineTagHelper.html#M000001">sparkline_tag</a>(User.registrations_report,
+:width => 200, :height => 100, :color => ‘000’) %>
+</p>
+ <p><a class="source-toggle" href="#"
+ onclick="toggleCode('M000001-source');return false;">[Source]</a></p>
+ <div class="method-source-code" id="M000001-source">
+<pre>
+ <span class="ruby-comment cmt"># File lib/kvlr/reports_as_sparkline/sparkline_tag_helper.rb, line 23</span>
+23: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sparkline_tag</span>(<span class="ruby-identifier">data</span>, <span class="ruby-identifier">options</span> = {})
+24: <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>({ <span class="ruby-identifier">:width</span> =<span class="ruby-operator">></span> <span class="ruby-value">300</span>, <span class="ruby-identifier">:height</span> =<span class="ruby-operator">></span> <span class="ruby-value">34</span>, <span class="ruby-identifier">:line_color</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'0077cc'</span>, <span class="ruby-identifier">:fill_color</span> =<span class="ruby-operator">></span> <span class="ruby-value str">'e6f2fa'</span>, <span class="ruby-identifier">:labels</span> =<span class="ruby-operator">></span> [] })
+25: <span class="ruby-identifier">data</span> = <span class="ruby-identifier">data</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-identifier">d</span>[<span class="ruby-value">1</span>] }
+26: <span class="ruby-identifier">labels</span> = <span class="ruby-value str">""</span>
+27: <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:labels</span>].<span class="ruby-identifier">empty?</span>
+28: <span class="ruby-identifier">labels</span> = <span class="ruby-node">"&chxt=#{options[:labels].map(&:to_s).join(',')}&chxr=0,0,#{data.length}|1,0,#{data.max}|2,0,#{data.max}|3,0,#{data.length}"</span>
+29: <span class="ruby-keyword kw">end</span>
+30: <span class="ruby-identifier">image_tag</span>(
+31: <span class="ruby-node">"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}"</span>
+32: )
+33: <span class="ruby-keyword kw">end</span>
+</pre>
+ </div>
+ </div>
+ </div>
+
+
+ </div>
+
+
+ </div>
+
+
+<div id="validator-badges">
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
+</div>
+
+</body>
+</html>
+\ No newline at end of file
(DIR) diff --git a/rdoc/created.rid b/rdoc/created.rid
@@ -1 +1 @@
-Thu, 15 Jan 2009 12:32:28 +0100
+Thu, 15 Jan 2009 16:53:33 +0100
(DIR) diff --git a/rdoc/files/README_rdoc.html b/rdoc/files/README_rdoc.html
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Thu Jan 15 11:59:48 +0100 2009</td>
+ <td>Thu Jan 15 16:53:21 +0100 2009</td>
</tr>
</table>
</div>
@@ -160,6 +160,27 @@ view:
<pre>
<%= sparkline_tag(User.registrations_report) %>
</pre>
+<p>
+The <tt>sparkline_tag</tt> helper takes the following parameters:
+</p>
+<ul>
+<li>width - The width of the generated image
+
+</li>
+<li>height - The height of the generated image
+
+</li>
+<li>line_color - The line color of the sparkline (hex code)
+
+</li>
+<li>fill_color - The color to fill the area below the sparkline with (hex code)
+
+</li>
+<li>labes - The axes to render lables for (Array of :x, :y, :r, :t; this is x
+axis, y axis, right, top)
+
+</li>
+</ul>
<h2>Installation</h2>
<p>
Installation requires 3 simple steps:
(DIR) diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline/asset_tag_helper_rb.html b/rdoc/files/lib/kvlr/reports_as_sparkline/asset_tag_helper_rb.html
@@ -1,101 +0,0 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<!DOCTYPE html
- PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
-<head>
- <title>File: asset_tag_helper.rb</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <meta http-equiv="Content-Script-Type" content="text/javascript" />
- <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
- <script type="text/javascript">
- // <![CDATA[
-
- function popupCode( url ) {
- window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
- }
-
- function toggleCode( id ) {
- if ( document.getElementById )
- elem = document.getElementById( id );
- else if ( document.all )
- elem = eval( "document.all." + id );
- else
- return false;
-
- elemStyle = elem.style;
-
- if ( elemStyle.display != "block" ) {
- elemStyle.display = "block"
- } else {
- elemStyle.display = "none"
- }
-
- return true;
- }
-
- // Make codeblocks hidden by default
- document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
-
- // ]]>
- </script>
-
-</head>
-<body>
-
-
-
- <div id="fileHeader">
- <h1>asset_tag_helper.rb</h1>
- <table class="header-table">
- <tr class="top-aligned-row">
- <td><strong>Path:</strong></td>
- <td>lib/kvlr/reports_as_sparkline/asset_tag_helper.rb
- </td>
- </tr>
- <tr class="top-aligned-row">
- <td><strong>Last Update:</strong></td>
- <td>Thu Jan 15 11:13:51 +0100 2009</td>
- </tr>
- </table>
- </div>
- <!-- banner header -->
-
- <div id="bodyContent">
-
-
-
- <div id="contextContent">
-
-
-
- </div>
-
-
- </div>
-
-
- <!-- if includes -->
-
- <div id="section">
-
-
-
-
-
-
-
-
- <!-- if method_list -->
-
-
- </div>
-
-
-<div id="validator-badges">
- <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
-</div>
-
-</body>
-</html>
-\ No newline at end of file
(DIR) diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline/grouping_rb.html b/rdoc/files/lib/kvlr/reports_as_sparkline/grouping_rb.html
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Thu Jan 15 11:13:51 +0100 2009</td>
+ <td>Thu Jan 15 15:32:06 +0100 2009</td>
</tr>
</table>
</div>
(DIR) diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline/report_rb.html b/rdoc/files/lib/kvlr/reports_as_sparkline/report_rb.html
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Thu Jan 15 12:32:02 +0100 2009</td>
+ <td>Thu Jan 15 15:32:37 +0100 2009</td>
</tr>
</table>
</div>
(DIR) diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline/sparkline_tag_helper_rb.html b/rdoc/files/lib/kvlr/reports_as_sparkline/sparkline_tag_helper_rb.html
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>File: sparkline_tag_helper.rb</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
+ <script type="text/javascript">
+ // <![CDATA[
+
+ function popupCode( url ) {
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
+ }
+
+ function toggleCode( id ) {
+ if ( document.getElementById )
+ elem = document.getElementById( id );
+ else if ( document.all )
+ elem = eval( "document.all." + id );
+ else
+ return false;
+
+ elemStyle = elem.style;
+
+ if ( elemStyle.display != "block" ) {
+ elemStyle.display = "block"
+ } else {
+ elemStyle.display = "none"
+ }
+
+ return true;
+ }
+
+ // Make codeblocks hidden by default
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
+
+ // ]]>
+ </script>
+
+</head>
+<body>
+
+
+
+ <div id="fileHeader">
+ <h1>sparkline_tag_helper.rb</h1>
+ <table class="header-table">
+ <tr class="top-aligned-row">
+ <td><strong>Path:</strong></td>
+ <td>lib/kvlr/reports_as_sparkline/sparkline_tag_helper.rb
+ </td>
+ </tr>
+ <tr class="top-aligned-row">
+ <td><strong>Last Update:</strong></td>
+ <td>Thu Jan 15 16:51:29 +0100 2009</td>
+ </tr>
+ </table>
+ </div>
+ <!-- banner header -->
+
+ <div id="bodyContent">
+
+
+
+ <div id="contextContent">
+
+
+
+ </div>
+
+
+ </div>
+
+
+ <!-- if includes -->
+
+ <div id="section">
+
+
+
+
+
+
+
+
+ <!-- if method_list -->
+
+
+ </div>
+
+
+<div id="validator-badges">
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
+</div>
+
+</body>
+</html>
+\ No newline at end of file
(DIR) diff --git a/rdoc/files/lib/kvlr/reports_as_sparkline_rb.html b/rdoc/files/lib/kvlr/reports_as_sparkline_rb.html
@@ -56,7 +56,7 @@
</tr>
<tr class="top-aligned-row">
<td><strong>Last Update:</strong></td>
- <td>Thu Jan 15 11:13:51 +0100 2009</td>
+ <td>Thu Jan 15 15:31:55 +0100 2009</td>
</tr>
</table>
</div>
(DIR) diff --git a/rdoc/fr_class_index.html b/rdoc/fr_class_index.html
@@ -20,12 +20,12 @@
<div id="index">
<h1 class="section-bar">Classes</h1>
<div id="index-entries">
- <a href="classes/Kvlr/ReportsAsSparkline/AssetTagHelper.html">Kvlr::ReportsAsSparkline::AssetTagHelper</a><br />
<a href="classes/Kvlr/ReportsAsSparkline/ClassMethods.html">Kvlr::ReportsAsSparkline::ClassMethods</a><br />
<a href="classes/Kvlr/ReportsAsSparkline/CumulatedReport.html">Kvlr::ReportsAsSparkline::CumulatedReport</a><br />
<a href="classes/Kvlr/ReportsAsSparkline/Grouping.html">Kvlr::ReportsAsSparkline::Grouping</a><br />
<a href="classes/Kvlr/ReportsAsSparkline/Report.html">Kvlr::ReportsAsSparkline::Report</a><br />
<a href="classes/Kvlr/ReportsAsSparkline/ReportingPeriod.html">Kvlr::ReportsAsSparkline::ReportingPeriod</a><br />
+ <a href="classes/Kvlr/ReportsAsSparkline/SparklineTagHelper.html">Kvlr::ReportsAsSparkline::SparklineTagHelper</a><br />
</div>
</div>
</body>
(DIR) diff --git a/rdoc/fr_file_index.html b/rdoc/fr_file_index.html
@@ -22,12 +22,12 @@
<div id="index-entries">
<a href="files/README_rdoc.html">README.rdoc</a><br />
<a href="files/lib/kvlr/reports_as_sparkline_rb.html">lib/kvlr/reports_as_sparkline.rb</a><br />
- <a href="files/lib/kvlr/reports_as_sparkline/asset_tag_helper_rb.html">lib/kvlr/reports_as_sparkline/asset_tag_helper.rb</a><br />
<a href="files/lib/kvlr/reports_as_sparkline/cumulated_report_rb.html">lib/kvlr/reports_as_sparkline/cumulated_report.rb</a><br />
<a href="files/lib/kvlr/reports_as_sparkline/grouping_rb.html">lib/kvlr/reports_as_sparkline/grouping.rb</a><br />
<a href="files/lib/kvlr/reports_as_sparkline/report_rb.html">lib/kvlr/reports_as_sparkline/report.rb</a><br />
<a href="files/lib/kvlr/reports_as_sparkline/report_cache_rb.html">lib/kvlr/reports_as_sparkline/report_cache.rb</a><br />
<a href="files/lib/kvlr/reports_as_sparkline/reporting_period_rb.html">lib/kvlr/reports_as_sparkline/reporting_period.rb</a><br />
+ <a href="files/lib/kvlr/reports_as_sparkline/sparkline_tag_helper_rb.html">lib/kvlr/reports_as_sparkline/sparkline_tag_helper.rb</a><br />
</div>
</div>
</body>
(DIR) diff --git a/rdoc/fr_method_index.html b/rdoc/fr_method_index.html
@@ -22,14 +22,14 @@
<div id="index-entries">
<a href="classes/Kvlr/ReportsAsSparkline/ReportingPeriod.html#M000007">first (Kvlr::ReportsAsSparkline::ReportingPeriod)</a><br />
<a href="classes/Kvlr/ReportsAsSparkline/Grouping.html#M000005">identifier (Kvlr::ReportsAsSparkline::Grouping)</a><br />
- <a href="classes/Kvlr/ReportsAsSparkline/Grouping.html#M000004">new (Kvlr::ReportsAsSparkline::Grouping)</a><br />
<a href="classes/Kvlr/ReportsAsSparkline/ReportingPeriod.html#M000006">new (Kvlr::ReportsAsSparkline::ReportingPeriod)</a><br />
+ <a href="classes/Kvlr/ReportsAsSparkline/Grouping.html#M000004">new (Kvlr::ReportsAsSparkline::Grouping)</a><br />
<a href="classes/Kvlr/ReportsAsSparkline/Report.html#M000009">new (Kvlr::ReportsAsSparkline::Report)</a><br />
<a href="classes/Kvlr/ReportsAsSparkline/ReportingPeriod.html#M000008">next (Kvlr::ReportsAsSparkline::ReportingPeriod)</a><br />
- <a href="classes/Kvlr/ReportsAsSparkline/ClassMethods.html#M000001">reports_as_sparkline (Kvlr::ReportsAsSparkline::ClassMethods)</a><br />
+ <a href="classes/Kvlr/ReportsAsSparkline/ClassMethods.html#M000002">reports_as_sparkline (Kvlr::ReportsAsSparkline::ClassMethods)</a><br />
<a href="classes/Kvlr/ReportsAsSparkline/CumulatedReport.html#M000003">run (Kvlr::ReportsAsSparkline::CumulatedReport)</a><br />
<a href="classes/Kvlr/ReportsAsSparkline/Report.html#M000010">run (Kvlr::ReportsAsSparkline::Report)</a><br />
- <a href="classes/Kvlr/ReportsAsSparkline/AssetTagHelper.html#M000002">sparkline_tag (Kvlr::ReportsAsSparkline::AssetTagHelper)</a><br />
+ <a href="classes/Kvlr/ReportsAsSparkline/SparklineTagHelper.html#M000001">sparkline_tag (Kvlr::ReportsAsSparkline::SparklineTagHelper)</a><br />
</div>
</div>
</body>
(DIR) diff --git a/spec/other/sparkline_tag_helper_spec.rb b/spec/other/sparkline_tag_helper_spec.rb
@@ -10,12 +10,28 @@ describe Kvlr::ReportsAsSparkline::SparklineTagHelper do
it 'should render an image with the correct source' 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'
+ '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'
)
@helper.sparkline_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTime.now, 3.0]])
end
+ it 'should add parameters for labels to the source of the image if rendering of lables is 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&chxt=x,y,r,t&chxr=0,0,3|1,0,3.0|2,0,3.0|3,0,3'
+ )
+
+ @helper.sparkline_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTime.now, 3.0]], :labels => [:x, :y, :r, :t])
+ end
+
+ it 'should set the parameters for custom colors if custom colors are 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=000000&chm=B,ffffff,0,0,0&chls=1,0,0&chds=1.0,3.0'
+ )
+
+ @helper.sparkline_tag([[DateTime.now, 1.0], [DateTime.now, 2.0], [DateTime.now, 3.0]], :line_color => '000000', :fill_color => 'ffffff')
+ end
+
end
end