Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Updating plotly chart width and height on parent resizing

I have a plotly chart inside custom directive in angularjs. Whenever the size of custom directive changes, I want to update the dimensions of chart so that it’ll fit. I want to leave other layout options as it is. How can I achieve this?

Try

Plotly.relayout('graph', {
  width: /* new width */,
  height: /* new height */
})

Thanks for that. Is there anyway to simply refresh/redraw the plot without changing data/layout parameters?

Why is that a problem?

I simply want to refresh the plot as I have implemented the resize logic.

You can try Plotly.Plots.resize, but it essentially does the same as relayout i.e. it changes the graph’s layout.width and layout.height.