Class: RailsDataExplorer::Exploration
- Inherits:
-
Object
- Object
- RailsDataExplorer::Exploration
- Defined in:
- lib/rails_data_explorer/exploration.rb
Overview
Responsibilities:
* Represent and initialize a data exploration
* Initialize and render self (including charts)
Collaborators:
* DataSet
* Chart
Instance Attribute Summary collapse
-
#charts ⇒ Object
Returns the value of attribute charts.
-
#data_set ⇒ Object
Returns the value of attribute data_set.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
-
.compute_dom_id(data_series_names) ⇒ String
Computes a dom_id for data_series_names.
Instance Method Summary collapse
- #dom_id ⇒ Object
-
#initialize(_title, data_set_or_array, render_charts, chart_specs = nil) ⇒ Exploration
constructor
Initializes a new visualization.
- #inspect(indent = 1, recursive = 1000) ⇒ Object
-
#render_charts? ⇒ Boolean
Returns true if charts for this exploration are to be rendered.
- #type_of_analysis ⇒ Object
Constructor Details
#initialize(_title, data_set_or_array, render_charts, chart_specs = nil) ⇒ Exploration
Initializes a new visualization.
40 41 42 43 44 45 |
# File 'lib/rails_data_explorer/exploration.rb', line 40 def initialize(_title, data_set_or_array, render_charts, chart_specs=nil) @title = _title @data_set = initialize_data_set(data_set_or_array) @render_charts = render_charts @charts = initialize_charts(chart_specs) end |
Instance Attribute Details
#charts ⇒ Object
Returns the value of attribute charts.
15 16 17 |
# File 'lib/rails_data_explorer/exploration.rb', line 15 def charts @charts end |
#data_set ⇒ Object
Returns the value of attribute data_set.
15 16 17 |
# File 'lib/rails_data_explorer/exploration.rb', line 15 def data_set @data_set end |
#title ⇒ Object
Returns the value of attribute title.
15 16 17 |
# File 'lib/rails_data_explorer/exploration.rb', line 15 def title @title end |
Class Method Details
.compute_dom_id(data_series_names) ⇒ String
Computes a dom_id for data_series_names
24 25 26 |
# File 'lib/rails_data_explorer/exploration.rb', line 24 def self.compute_dom_id(data_series_names) "rde-exploration-#{ data_series_names.sort.map { |e| e.parameterize('') }.join('-') }" end |
Instance Method Details
#dom_id ⇒ Object
52 53 54 |
# File 'lib/rails_data_explorer/exploration.rb', line 52 def dom_id self.class.compute_dom_id(data_series_names) end |
#inspect(indent = 1, recursive = 1000) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rails_data_explorer/exploration.rb', line 56 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_charts? ⇒ Boolean
Returns true if charts for this exploration are to be rendered.
48 49 50 |
# File 'lib/rails_data_explorer/exploration.rb', line 48 def render_charts? @render_charts end |
#type_of_analysis ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/rails_data_explorer/exploration.rb', line 68 def type_of_analysis case @data_set.dimensions_count when 0 '[No data given]' when 1 'Univariate' when 2 'Bivariate' else 'Multivariate' end end |