lib/plotly/offline/templates/body.erb
<% if @embedded %>
<script>
requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min'] }})
</script>
<% else %>
<script>
<%= LOCAL_PLOTLY_JS %>
</script>
<% end %>
<div id="<%= @id %>" style="height: 100%; width: 100%;"></div>
<script>
<% if @embedded %> require(['plotly'], function(Plotly) { <% end %>
Plotly.newPlot(
<%= "'#{@id}'" %>,
<%= @data.to_json %>,
<%= @layout.to_json %>,
<%= @config.to_json %>
)
window.addEventListener('resize', function() {
Plotly.Plots.resize(document.getElementById('<%= @id %>'))
})
<% if @embedded %> }) <% end %>
</script>