Class: Plotly::Offline::HTML
Constant Summary collapse
- DEFAULT_CONFIG =
{ linkText: 'Export to plot.ly', showLink: true }.freeze
- PLOTLY_JS_CDN_URL =
'https://cdn.plot.ly/plotly-latest.min'.freeze
- LOCAL_PLOTLY_JS =
File.read(File.('../plotly.min.js', __FILE__))
Instance Method Summary collapse
-
#initialize(id, data, layout: {}, config: DEFAULT_CONFIG, embedded: false) ⇒ HTML
constructor
A new instance of HTML.
-
#render ⇒ String
HTML document.
-
#to_iruby ⇒ Array
This method is used to embed plots into IRuby notebooks.
Constructor Details
#initialize(id, data, layout: {}, config: DEFAULT_CONFIG, embedded: false) ⇒ HTML
Returns a new instance of HTML.
16 17 18 19 20 21 22 |
# File 'lib/plotly/offline/html.rb', line 16 def initialize(id, data, layout: {}, config: DEFAULT_CONFIG, embedded: false) @id = id @data = data @layout = layout @config = config = end |
Instance Method Details
#render ⇒ String
Returns HTML document.
25 26 27 28 29 30 |
# File 'lib/plotly/offline/html.rb', line 25 def render template_name = ? :body : :plot template = template_for(template_name) erb = ERB.new(template) erb.result(binding) end |
#to_iruby ⇒ Array
This method is used to embed plots into IRuby notebooks.
34 35 36 |
# File 'lib/plotly/offline/html.rb', line 34 def to_iruby ['text/html', render] end |