Module: Daru::Plotly
- Included in:
- DataFrame, Vector
- Defined in:
- lib/daru/plotly.rb,
lib/daru/plotly/vector.rb,
lib/daru/plotly/methods.rb,
lib/daru/plotly/version.rb,
lib/daru/plotly/dataframe.rb
Overview
Common methods for DataFrame and Vector
Defined Under Namespace
Modules: DataFrame, Methods, Vector
Constant Summary
collapse
- VERSION =
'0.2.0'.freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.default_layout ⇒ Object
19
20
21
22
23
24
|
# File 'lib/daru/plotly.rb', line 19
def default_layout
{
width: 1000,
height: 500
}
end
|
26
27
28
|
# File 'lib/daru/plotly.rb', line 26
def (modes)
(Array(modes) || [:markers]).map(&:to_s).join('+')
end
|
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/daru/plotly.rb', line 30
def (plot_type)
case plot_type
when nil
:scatter
when *supported_types
plot_type
else
raise ArgumentError, "Type must be included in #{supported_types}."
end
end
|
Instance Method Details
#plot(source, opts = {}) {|plot| ... } ⇒ Object
10
11
12
13
14
15
16
17
|
# File 'lib/daru/plotly.rb', line 10
def plot(source, opts = {})
data = opts[:data] || generate_data(source, opts)
layout = default_layout.merge(opts[:layout] || {})
plot = ::Plotly::Plot.new(data: data, layout: layout)
yield plot if block_given?
plot
end
|