class Quby::Questionnaires::Entities::Charting::Chart
Attributes
@return [Symbol]
@return [Symbol]
@return [Array]
@return [Array]
@return [Array]
@return [Float]
@return [String]
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
@return [Array]
@return [Range]
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.
@return [Hash<Range, String>]
Public Class Methods
# 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
Public Instance Methods
# File lib/quby/questionnaires/entities/charting/chart.rb, line 87 def chart_type=(value) @chart_type = value&.to_sym end
# File lib/quby/questionnaires/entities/charting/chart.rb, line 91 def default_y_range # when there are y_categories, the y_range should match the # number of categories (validated in chart_builder#validate!) (0..(y_categories.count - 1)) if y_categories.present? # otherwise, nil is allowed as a y_range end
# File lib/quby/questionnaires/entities/charting/chart.rb, line 79 def type self.class.name.to_s.demodulize.underscore end