Can Plotly offset the legend from the axis automatically?

I am working with plotly for javascript.
I am receiving data from forms in order to determine where the legend will be displayed.
But I discovered that the y axis titles and the legend overlap themselves.
Here’s my example :

Is there any possibilities to automatically offset the legend in order to avoid any overlap with the axis and their labels?
Like if there is a right axis with the title, legend.x’s offset is 1.05 (which seems to do the trick in this case) instead of 1.
Thank you!

I’m looking to solve this same issue, did you ever find a resolution?

There was something about multiple axes, not sure if this helps you, though

Thank you, was definitely helpful to look at, but still doesn’t solve the issue of distancing the legend from the axis title automatically