Class: Spout::Models::Graphables::Default
- Inherits:
-
Object
- Object
- Spout::Models::Graphables::Default
show all
- Defined in:
- lib/spout/models/graphables/default.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(variable, chart_variable, stratification_variable, subjects) ⇒ Default
Returns a new instance of Default.
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/spout/models/graphables/default.rb', line 12
def initialize(variable, chart_variable, stratification_variable, subjects)
@variable = variable
@chart_variable = chart_variable
@stratification_variable = stratification_variable
@subjects = subjects
begin
@values_unique = subjects.collect(&@variable.id.to_sym).reject { |a| a.is_a?(Spout::Models::Empty) }.uniq
rescue
@values_unique = []
end
@buckets = continuous_buckets
end
|
Instance Attribute Details
#chart_variable ⇒ Object
Returns the value of attribute chart_variable.
10
11
12
|
# File 'lib/spout/models/graphables/default.rb', line 10
def chart_variable
@chart_variable
end
|
#stratification_variable ⇒ Object
Returns the value of attribute stratification_variable.
10
11
12
|
# File 'lib/spout/models/graphables/default.rb', line 10
def stratification_variable
@stratification_variable
end
|
#subjects ⇒ Object
Returns the value of attribute subjects.
10
11
12
|
# File 'lib/spout/models/graphables/default.rb', line 10
def subjects
@subjects
end
|
#variable ⇒ Object
Returns the value of attribute variable.
10
11
12
|
# File 'lib/spout/models/graphables/default.rb', line 10
def variable
@variable
end
|
Instance Method Details
#categories ⇒ Object
49
50
51
|
# File 'lib/spout/models/graphables/default.rb', line 49
def categories
[]
end
|
#series ⇒ Object
57
58
59
|
# File 'lib/spout/models/graphables/default.rb', line 57
def series
[]
end
|
#stacking ⇒ Object
61
62
63
|
# File 'lib/spout/models/graphables/default.rb', line 61
def stacking
nil
end
|
#subtitle ⇒ Object
45
46
47
|
# File 'lib/spout/models/graphables/default.rb', line 45
def subtitle
"By Visit"
end
|
#title ⇒ Object
41
42
43
|
# File 'lib/spout/models/graphables/default.rb', line 41
def title
"#{@variable.display_name} by #{@chart_variable.display_name}"
end
|
#to_hash ⇒ Object
25
26
27
|
# File 'lib/spout/models/graphables/default.rb', line 25
def to_hash
{ title: title, subtitle: subtitle, categories: categories, units: units, series: series, stacking: stacking, x_axis_title: x_axis_title } if valid?
end
|
#units ⇒ Object
53
54
55
|
# File 'lib/spout/models/graphables/default.rb', line 53
def units
nil
end
|
#valid? ⇒ Boolean
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/spout/models/graphables/default.rb', line 29
def valid?
if @variable.nil? || @chart_variable.nil? || @values_unique == []
false
elsif @variable.type == "choices" && @variable.domain.options == []
false
elsif @chart_variable.type == "choices" && @chart_variable.domain.options == []
false
else
true
end
end
|
#x_axis_title ⇒ Object
65
66
67
|
# File 'lib/spout/models/graphables/default.rb', line 65
def x_axis_title
nil
end
|