Method: Charty::Backends::PlotlyHelpers::HtmlRenderer#render

Defined in:
lib/charty/backends/plotly_helpers/html_renderer.rb

#render(figure, element_id: nil, post_script: nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/charty/backends/plotly_helpers/html_renderer.rb', line 24

def render(figure, element_id: nil, post_script: nil)
  element_id = SecureRandom.uuid if element_id.nil?
  plotly_html_div = build_plotly_html_div(figure, element_id, post_script)

  if @full_html
    "      <!DOCTYPE html>\n      <html>\n      <head><meta charset=\"utf-8\" /></head>\n      <body>\n        %{div}\n      </body>\n      </html>\n    END_HTML\n  else\n    plotly_html_div\n  end\nend\n" % {div: plotly_html_div}