Class: Plotly::Plot
- Includes:
- Exportable, Offline::Exportable
- Defined in:
- lib/plotly/plot.rb
Instance Attribute Summary collapse
-
#data ⇒ Array
List of Plotly::Data objects.
-
#layout ⇒ Object
Returns the value of attribute layout.
Instance Method Summary collapse
- #add_data(data = Data.new) ⇒ Object
-
#initialize(data: [], layout: {}) ⇒ Plot
constructor
A new instance of Plot.
Methods included from Offline::Exportable
Methods included from Exportable
Constructor Details
#initialize(data: [], layout: {}) ⇒ Plot
Returns a new instance of Plot.
19 20 21 22 |
# File 'lib/plotly/plot.rb', line 19 def initialize(data: [], layout: {}) @data = data.map { |d| d.is_a?(Hash) ? Data.new(d) : d } @layout = layout.convert_to(Plotly::Layout) end |
Instance Attribute Details
#data ⇒ Array
Returns list of Plotly::Data objects.
15 16 17 |
# File 'lib/plotly/plot.rb', line 15 def data @data end |
#layout ⇒ Object
Returns the value of attribute layout.
15 |
# File 'lib/plotly/plot.rb', line 15 attr_reader :data, :layout |
Instance Method Details
#add_data(data = Data.new) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/plotly/plot.rb', line 25 def add_data(data = Data.new) @data.push begin case data when Data then data when Hash then Data.new(data) end end end |