Class: Plotly::Layout

Inherits:
Object show all
Includes:
Castable
Defined in:
lib/plotly/layout.rb

Constant Summary collapse

ATTRS =
%i(title barmode xaxis yaxis width height).freeze
AXISES =
%i(xaxis yaxis).freeze

Instance Method Summary collapse

Methods included from Castable

#to_h

Constructor Details

#initialize(opts = {}) ⇒ Layout

Returns a new instance of Layout.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • title (String)
  • barmode (String)
  • xaxis (Hash)
  • yaxis (Hash)


17
18
19
20
21
22
23
24
# File 'lib/plotly/layout.rb', line 17

def initialize(opts = {})
  return unless opts.is_a?(Hash)

  opts.each do |k, v|
    v.convert_to(Plotly::Axis) if AXISES.include?(k)
    instance_variable_set("@#{k}", v)
  end
end