How to let the user delete lines that were created by using 'draw line' button

200 views Asked by At

I have some plotly graphs in my javascript code that I can draw lines on by adding the following button via plotly's configuration settings:

{modeBarButtonsToAdd: ['drawline',...]}.

Now, I have not been able to find a button or plotly function to be able to delete lines after they have been drawn. Lets say the user draws three lines, and decides to click on one of them with the intent to delete only that specific line. Is there a specific button or plotly function I can add or is this functionality something I will need to create from scratch. After searching the internet, I haven't been able to find any 'delete drawings' function provided by plotly.

Thanks in advance!

1

There are 1 answers

0
Whip On

Silly me, after all my searching I missed the ability to add the 'eraseshape' button.

{modeBarButtonsToAdd: ['drawline','eraseshape'...]}.

Code above will add a button that will delete the actively selected shape (or in my case line) when pressed.