Class: RCharts::GraphHelper::Graph::Axes
- Inherits:
-
Object
- Object
- RCharts::GraphHelper::Graph::Axes
- Defined in:
- app/helpers/rcharts/graph_helper/graph/axes.rb
Overview
:nodoc:
Instance Method Summary collapse
- #continuous ⇒ Object
- #discrete ⇒ Object
- #fetch(name, index = 0) ⇒ Object
-
#initialize(graphable = {}, axis_options = {}) ⇒ Axes
constructor
A new instance of Axes.
Constructor Details
#initialize(graphable = {}, axis_options = {}) ⇒ Axes
Returns a new instance of Axes.
9 10 11 12 13 |
# File 'app/helpers/rcharts/graph_helper/graph/axes.rb', line 9 def initialize(graphable = {}, = {}) @axes = Options.new(graphable.keys, ).to_h do |name, axes| [name, axes.collect { |index, | build_axis(graphable:, name:, index:, **) }] end end |
Instance Method Details
#continuous ⇒ Object
24 25 26 |
# File 'app/helpers/rcharts/graph_helper/graph/axes.rb', line 24 def continuous fetch(:y).then { !it.discrete? && it } || axes.values.flatten.find { !it.discrete? } || fetch(:y) end |
#discrete ⇒ Object
20 21 22 |
# File 'app/helpers/rcharts/graph_helper/graph/axes.rb', line 20 def discrete fetch(:x).then { it.discrete? && it } || axes.values.flatten.find(&:discrete?) || fetch(:x) end |
#fetch(name, index = 0) ⇒ Object
15 16 17 18 |
# File 'app/helpers/rcharts/graph_helper/graph/axes.rb', line 15 def fetch(name, index = 0) axes.fetch(name) { raise ArgumentError, "Unknown axis #{name}" } .fetch(index) { raise ArgumentError, "Unknown index #{index} for axis #{name}" } end |