Position Plotly tooltip

Hi @etienne, could you please show me how to do it, currently i am following to create a new div and transforming the div based on the x and y co-ordinates, it is working if the user didnt resize the window.

for example: tooltip.style.transform = translate(calc(${data.event.x}px - 56%), calc(${data.event.y}px - 35%);

but this is not helping with the above tooltip usecase or the one i asked Plotly Relayout and Popup box on the click of the line chart
and you pointed me to the different thread. How to customize Plotly Tooltip
which is also not helping.