Add custom modeBar Button in Python

Hi everyone,

I am working with Dash and implemented multiple plottly graphs. I would like to add a custom modeBar button and found the config “modeBarButtonsToAdd”. How would I add a button to it?

And sorry for asking again, as I found this question multiple times but there was never a full working example to understand how the solution works.

Thanks in advance for any help!

1 Like

Write a JavaScript function that searches for the modeBar and appends your custom button to it. This function will be called after the graph is fully loaded. Use Dash’s clientside_callback to trigger your JavaScript function. The callback should be set up to execute after a short delay, ensuring the graph is loaded before the button is added. netbenefits fidelity com The setTimeout function is used to delay the execution of your JavaScript function by a specified number of milliseconds (e.g., 300ms). It’s important to note that setTimeout executes only once, unlike setInterval, which repeats the execution at intervals. To make sure the custom button is added after the graph is fully loaded, you can use the dcc.Loading component in Dash to wrap your graph. This way, the JavaScript function to add the button can be called after the loading is complete.