blog / src /plotting.js
clefourrier's picture
clefourrier HF staff
Squash entire repository history into a single commit
1f5f1cc
raw
history blame contribute delete
No virus
622 Bytes
// 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