Class: Charting::Sparklines::Renderer
- Inherits:
-
Object
- Object
- Charting::Sparklines::Renderer
- Defined in:
- lib/ar_to_chart/charting/sparklines.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :type => :line, }
Instance Attribute Summary collapse
-
#chart ⇒ Object
Returns the value of attribute chart.
-
#options ⇒ Object
Returns the value of attribute options.
-
#series ⇒ Object
Returns the value of attribute series.
Class Method Summary collapse
-
.configure {|_self| ... } ⇒ Object
Convenience method for configuring the chart.
Instance Method Summary collapse
-
#initialize(data_source, data_column, options = {}) ⇒ Renderer
constructor
Generate jQuery sparkline based charts.
-
#to_html ⇒ Object
Output the HTML representation of the chart.
Constructor Details
#initialize(data_source, data_column, options = {}) ⇒ Renderer
Generate jQuery sparkline based charts.
Ensure jquery-sparkine library is loaded before use, for example:
<script src="/javascripts/jquery.sparkline.js" type="text/javascript"></script>
And that you invoke somethink like:
/* Initialize sparklines */
$(document).ready(function() {
$('.sparkline').sparkline();
});
in your document script.
Styling in CSS is required for the <span> container which has a class of ‘sparkline’
Parameters
data_source: The active record result set
data_column: one column name to be charted
options: options hash
Options
Currently no options for Sparklines.
37 38 39 40 41 42 |
# File 'lib/ar_to_chart/charting/sparklines.rb', line 37 def initialize(data_source, data_column, = {}) @options = DEFAULT_OPTIONS.merge() @options[:container] ||= generate_container_name @data_column = data_column @chart = chart_class.new(data_source, @data_column, @options) end |
Instance Attribute Details
#chart ⇒ Object
Returns the value of attribute chart.
8 9 10 |
# File 'lib/ar_to_chart/charting/sparklines.rb', line 8 def chart @chart end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/ar_to_chart/charting/sparklines.rb', line 8 def @options end |
#series ⇒ Object
Returns the value of attribute series.
8 9 10 |
# File 'lib/ar_to_chart/charting/sparklines.rb', line 8 def series @series end |
Class Method Details
.configure {|_self| ... } ⇒ Object
Convenience method for configuring the chart.
50 51 52 |
# File 'lib/ar_to_chart/charting/sparklines.rb', line 50 def self.configure yield self end |
Instance Method Details
#to_html ⇒ Object
Output the HTML representation of the chart
45 46 47 |
# File 'lib/ar_to_chart/charting/sparklines.rb', line 45 def to_html @chart.to_html end |