Spaces:
Running
Running
// Get all plots on the page | |
// | |
const updatePlotSizes = () => { | |
const plots = document.querySelectorAll('.plotly-graph-div'); | |
plots.forEach(plot => { | |
console.log(plot.parentElement.parentElement.offsetWidth); | |
if (plot.parentElement.parentElement.offsetWidth > 0) { | |
Plotly.relayout(plot, { | |
width: plot.parentElement.parentElement.offsetWidth, | |
}); | |
} | |
}); | |
} | |
// Function to update plot sizes | |
export function initResizing() { | |
updatePlotSizes(); | |
window.addEventListener('resize', updatePlotSizes); | |
} | |
// Add event listener for window resize | |