<div>
<div id="{{ plot_div_id }}" class="plotly-graph-div" style="height:100%; width:100%;"></div>
<script type="text/javascript">
require(['https://cdn.plot.ly/plotly-2.8.3.min.js'], function(Plotly) {
window.PLOTLYENV=window.PLOTLYENV || {};
if (document.getElementById("{{ plot_div_id }}")) {
{{ plot_data }}
Plotly.newPlot(
'{{ plot_div_id }}',
data,
layout,
{"responsive": true}
).then(function(){
var gd = document.getElementById('{{ plot_div_id }}');
var x = new MutationObserver(function (mutations, observer) { {
var display = window.getComputedStyle(gd).display;
if (!display || display === 'none') { {
console.log([gd, 'removed!']);
Plotly.purge(gd);
observer.disconnect();
} }
} });
var notebookContainer = gd.closest('#notebook-container');
if (notebookContainer) { {
x.observe(notebookContainer, {childList: true});
} }
var outputEl = gd.closest('.output');
if (outputEl) { {
x.observe(outputEl, {childList: true});
} } })
};
});
</script>
</div>