Class: RCharts::GraphHelper::Graph::Axis::Domain
- Inherits:
-
Object
- Object
- RCharts::GraphHelper::Graph::Axis::Domain
- Defined in:
- app/helpers/rcharts/graph_helper/graph/axis/domain.rb
Overview
:nodoc:
Constant Summary collapse
- FLOOR_ALIGNMENT =
{ ...(2.days.to_i) => -> { it.beginning_of_day }, (2.days.to_i)...(2.weeks.to_i) => -> { it.beginning_of_week }, (2.weeks.to_i)...(2.months.to_i) => -> { it.beginning_of_month }, (2.months.to_i)...(4.months.to_i) => -> { it.beginning_of_quarter }, (4.months.to_i)...(10.months.to_i) => -> { it.beginning_of_year.advance(months: it.month < 7 ? 0 : 6) }, (10.months.to_i)... => -> { it.beginning_of_year } }.freeze
- MODES =
%i[exact rounded].freeze
Instance Method Summary collapse
- #domain_maximum ⇒ Object
- #domain_minimum ⇒ Object
- #exact? ⇒ Boolean
-
#initialize(minimum:, maximum:, tick_interval:, mode:) ⇒ Domain
constructor
A new instance of Domain.
- #rounded? ⇒ Boolean
Constructor Details
#initialize(minimum:, maximum:, tick_interval:, mode:) ⇒ Domain
Returns a new instance of Domain.
16 17 18 19 20 21 |
# File 'app/helpers/rcharts/graph_helper/graph/axis/domain.rb', line 16 def initialize(minimum:, maximum:, tick_interval:, mode:) @minimum = minimum @maximum = maximum @tick_interval = tick_interval @mode = mode.presence_in(MODES) || raise(ArgumentError, "mode must be one of #{MODES.collect(&:inspect).join(', ')}") end |
Instance Method Details
#domain_maximum ⇒ Object
29 30 31 32 33 |
# File 'app/helpers/rcharts/graph_helper/graph/axis/domain.rb', line 29 def domain_maximum return maximum if exact? adjusted_maximum end |
#domain_minimum ⇒ Object
23 24 25 26 27 |
# File 'app/helpers/rcharts/graph_helper/graph/axis/domain.rb', line 23 def domain_minimum return minimum if exact? adjusted_minimum end |
#exact? ⇒ Boolean
35 36 37 |
# File 'app/helpers/rcharts/graph_helper/graph/axis/domain.rb', line 35 def exact? mode == :exact end |
#rounded? ⇒ Boolean
39 40 41 |
# File 'app/helpers/rcharts/graph_helper/graph/axis/domain.rb', line 39 def rounded? mode == :rounded end |