class Quby::Compiler::Entities::Charting::Chart

Attributes

chart_type[RW]

@return [Symbol]

key[RW]

@return [Symbol]

plotbands[RW]

@return [Array]

plotlines[RW]

@return [Array]

plottables[RW]

@return [Array]

tick_interval[RW]

@return [Float]

title[RW]

@return [String]

y_categories[RW]

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]

y_range[RW]

@return [Range]

y_range_categories[RW]

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

new(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) click to toggle source
# File lib/quby/compiler/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

chart_type=(value) click to toggle source
# File lib/quby/compiler/entities/charting/chart.rb, line 87
def chart_type=(value)
  @chart_type = value&.to_sym
end
default_y_range() click to toggle source
# File lib/quby/compiler/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
type() click to toggle source
# File lib/quby/compiler/entities/charting/chart.rb, line 79
def type
  self.class.name.to_s.demodulize.underscore
end