Class: RailsDataExplorer::Exploration
- Inherits:
-
Object
- Object
- RailsDataExplorer::Exploration
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- lib/rails-data-explorer/exploration.rb
Instance Attribute Summary collapse
-
#charts ⇒ Object
Returns the value of attribute charts.
-
#data_set ⇒ Object
Returns the value of attribute data_set.
-
#output_buffer ⇒ Object
required for content_tag.
-
#title ⇒ Object
Returns the value of attribute title.
Instance Method Summary collapse
- #dom_id ⇒ Object
-
#initialize(_title, data_set_or_array, chart_specs = nil) ⇒ Exploration
constructor
Initializes a new visualization.
- #inspect(indent = 1, recursive = 1000) ⇒ Object
- #render ⇒ Object
- #type_of_analysis ⇒ Object
Constructor Details
#initialize(_title, data_set_or_array, chart_specs = nil) ⇒ Exploration
Initializes a new visualization. @param _title will be printed at top of visualization @param data_set_or_array can be a number of things:
* Array<Scalar> - for single data series, uni-variate options are applied.
* Array<Hash> - for multiple data series, bi/multi-variate options are applied.
* DataSet - For finer grained control.
@param[Array<Chart, String, Symbol>, optional] chart_specs
The list of charts to include. Defaults to all applicable charts for the
given data_set_or_array.
Charts can be provided as Array of Strings, Symbols, or Chart classes
(can be mixed).
22 23 24 25 26 |
# File 'lib/rails-data-explorer/exploration.rb', line 22 def initialize(_title, data_set_or_array, chart_specs=nil) @title = _title @data_set = initialize_data_set(data_set_or_array) @charts = initialize_charts(chart_specs) end |
Instance Attribute Details
#charts ⇒ Object
Returns the value of attribute charts.
7 8 9 |
# File 'lib/rails-data-explorer/exploration.rb', line 7 def charts @charts end |
#data_set ⇒ Object
Returns the value of attribute data_set.
7 8 9 |
# File 'lib/rails-data-explorer/exploration.rb', line 7 def data_set @data_set end |
#output_buffer ⇒ Object
required for content_tag
4 5 6 |
# File 'lib/rails-data-explorer/exploration.rb', line 4 def output_buffer @output_buffer end |
#title ⇒ Object
Returns the value of attribute title.
7 8 9 |
# File 'lib/rails-data-explorer/exploration.rb', line 7 def title @title end |
Instance Method Details
#dom_id ⇒ Object
44 45 46 |
# File 'lib/rails-data-explorer/exploration.rb', line 44 def dom_id "rde-exploration-#{ object_id }" end |
#inspect(indent = 1, recursive = 1000) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rails-data-explorer/exploration.rb', line 48 def inspect(indent=1, recursive=1000) r = %(#<#{ self.class.to_s }\n) r << [ "@title=#{ @title.inspect }", ].map { |e| "#{ ' ' * indent }#{ e }\n"}.join if recursive > 0 r << %(#{ ' ' * indent }@data_set=) r << data_set.inspect(indent + 1, recursive - 1) end r << %(#{ ' ' * (indent-1) }>\n) end |
#render ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rails-data-explorer/exploration.rb', line 28 def render content_tag(:div, class: 'rde-exploration panel panel-default', id: dom_id) do content_tag(:div, class: 'panel-heading') do %(<span style="float: right;"><a href="#rails_data_explorer-toc">Top</a></span>).html_safe + content_tag(:h2, @title, class: 'rde-exploration-title panel-title') end + content_tag(:div, class: 'panel-body') do if @charts.any? @charts.map { |e| e.render }.join.html_safe else "No charts are available for this combination of data series." end end end.html_safe end |
#type_of_analysis ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/rails-data-explorer/exploration.rb', line 60 def type_of_analysis case @data_set.dimensions_count when 0 '[No data given]' when 1 'Univariate' when 2 'Bivariate' else 'Multivariate' end end |