Class: Quby::Questionnaires::Entities::Charting::Chart
- Inherits:
-
Object
- Object
- Quby::Questionnaires::Entities::Charting::Chart
show all
- Defined in:
- lib/quby/questionnaires/entities/charting/chart.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(key, title: nil, plottables: nil, y_categories: nil, y_range_categories: nil, chart_type: nil, y_range: nil, tick_interval: nil, plotbands: nil, plotlines: nil) ⇒ Chart
Returns a new instance of Chart.
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 66
def initialize(key, title: nil, plottables: nil, y_categories: nil, y_range_categories: nil, chart_type: nil, y_range: nil, tick_interval: nil, plotbands: nil, plotlines: nil)
self.key = key.to_sym
self.title = title
self.plottables = plottables || []
self.y_categories = y_categories
self.y_range_categories = y_range_categories
self.chart_type = chart_type
self.y_range = y_range
self.tick_interval = tick_interval
self.plotbands = plotbands || []
self.plotlines = plotlines || []
end
|
Instance Attribute Details
#chart_type ⇒ Symbol
52
53
54
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 52
def chart_type
@chart_type
end
|
#key ⇒ Symbol
9
10
11
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 9
def key
@key
end
|
#plotbands ⇒ Array
61
62
63
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 61
def plotbands
@plotbands
end
|
#plotlines ⇒ Array
64
65
66
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 64
def plotlines
@plotlines
end
|
#plottables ⇒ Array
15
16
17
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 15
def plottables
@plottables
end
|
#tick_interval ⇒ Float
58
59
60
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 58
def tick_interval
@tick_interval
end
|
#title ⇒ String
12
13
14
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 12
def title
@title
end
|
#y_categories ⇒ Array
If y_categories are defined, plottable values should correspond to values from this array and the graph will be plotted with corresponding y axis categories example (icl_r):
["Zeer laag", "Laag", "Gemiddeld", "Hoog", "Zeer Hoog"]
(caution, capitalization oddity)
NB: only implemented for bar charts on the roqua side
28
29
30
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 28
def y_categories
@y_categories
end
|
#y_range ⇒ Range
55
56
57
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 55
def y_range
@y_range
end
|
#y_range_categories ⇒ Hash<Range, String>
If y_range_categories are defined, plottable values should fall in the ranges that compose the keys of this hash. The chart will label these ranges of y_values with the corresponding value in the hash on the y axis. For example:
{
(0.0...30.0) => "Zeer laag",
(30.0...40.0) => "Laag",
(40.0...60.0) => "Gemiddeld",
(60.0...70.0) => "Hoog",
(70.0..100.0) => "Zeer hoog"
}
NB: .. is inclusive the last value in the range, … is exclusive.
ChartBuilder#y_range_categories massages its parameters into this format. Only implemented for line charts on the RoQua side.
49
50
51
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 49
def y_range_categories
@y_range_categories
end
|
Instance Method Details
#default_y_range ⇒ Object
91
92
93
94
95
96
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 91
def default_y_range
(0..(y_categories.count - 1)) if y_categories.present?
end
|
#type ⇒ Object
79
80
81
|
# File 'lib/quby/questionnaires/entities/charting/chart.rb', line 79
def type
self.class.name.to_s.demodulize.underscore
end
|