On this link, you can find a workaround using clientside-callback https://github.com/plotly/plotly.py/issues/2114#issuecomment-2163720263