My project involves creating a webpage with dynamic div elements that resize upon mouseover using a straightforward CSS class. I've set it up so that these divs start off small when the page loads, but expand when a user hovers over them.
The CSS code looks something like this:
.resize {
width: 400px;
height: 300px;
transition: all 1s;
}
.resize:hover {
width: 800px;
height: 600px;
}
I am currently working on making the plots generated by Plotly.js within these divs automatically adjust their size as the user hovers over them.
Here's the JavaScript function for creating the graphs:
function doGraph() {
for(index = 0; index < divArr.length; ++index) {
(function() {
var d3 = Plotly.d3;
var gd3 = d3.select("div[id='"+divArr[index]+"']");
//.append('div')
//.style({
// width: "95%", "margin-left": "2.5%",
// height: "95%", "margin-top": "2.5%"
//});
var gd = gd3.node();
Plotly.newPlot(gd, [{
mode:'lines',
x: xArr[index],
y: yArr[index], }],
layout , {scrollZoom:true,modeBarButtonsToRemove:['sendDataToCloud'],showLink:false,displaylogo:false});
window.addEventListener('resize', function() { Plotly.Plots.relayout(gd); });
})();
}
}
The section of commented out code indicates where I'm uncertain about how to make everything function as intended. I've tried various approaches without success so far.
All the content on the page is dynamically generated in C# code based on text files provided by users.
A related question that I came across can be found here, but I'm unsure if and how it applies to my specific implementation.