Automatic resizing or responsive behaviour, how?

I got to grips with plotly and I’m really happy with what I can achieve, however I cant make any headway with doing something responsive or adaptive for a web page.
I found this example https://plot.ly/javascript/responsive-fluid-layout/
but I dont understand it and the code in the pen cant be the whole story. I apologise in that I know simple Javascript pretty well really, but that code looks like nothing I ever saw.
I begins with var d3 = Plotly.d3; ? how can it do that? what is Plotly.d3?
If anyone could please give a few simple pointers how I can make it resize when the bounding div is resized, I would be really grateful.

Thanks