Class: Trackplot::Components::Axis

Inherits:
Base
  • Object
show all
Defined in:
lib/trackplot/components/axis.rb

Constant Summary collapse

FORMAT_SYMBOLS =
{
  currency: "currency",
  percent: "percent",
  compact: "compact",
  decimal: "decimal",
  integer: "integer"
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#type

Constructor Details

#initialize(direction, **options) ⇒ Axis

Returns a new instance of Axis.



14
15
16
17
# File 'lib/trackplot/components/axis.rb', line 14

def initialize(direction, **options)
  @direction = direction.to_s
  super(**options)
end

Instance Attribute Details

#directionObject (readonly)

Returns the value of attribute direction.



12
13
14
# File 'lib/trackplot/components/axis.rb', line 12

def direction
  @direction
end

Instance Method Details

#to_configObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/trackplot/components/axis.rb', line 19

def to_config
  {
    type: "axis",
    direction: direction,
    data_key: options[:data_key],
    label: options[:label],
    format: resolve_format(options[:format]),
    tick_count: options[:tick_count],
    tick_rotation: options[:tick_rotation],
    axis_id: options[:axis_id]&.to_s
  }.compact
end