Setting max width of bar

Hi. I’m trying to force a max bar width for a responsive barchart.

To do so i’m using the event afterPlot to figure out the ratio that I need to set in the data[trace position].width (using the width of the div where the plot is and the max width that I want in px).

To force a re-render I update the revision and everything works fine but I have the following error:
Uncaught (in promise) TypeError: Cannot read property ‘_rehover’ of undefined
at plots.rehover (plotly-basic.js:63058)
at Object.lib.syncOrAsync (plotly-basic.js:36865)
at continueAsync (plotly-basic.js:36860)

I think maybe I’m messing up the lifecycle of plotly or something like that…

Many thanks.