I am trying to make the scatter plot update when I drag some shapes in plotly. The shapes are "handles" for the whole graph. The scatter plot doesn't update even though I've dragged the shapes and the Y values should have changed. I think this code javascript - Draggable line chart in R/Shiny - Stack Overflow (the one at the bottom) is something I could use but I'm too inexperienced to understand it.
Here's my code
Hi @Rankineplant. This feature is tricky. You have to define the circle objects and overlay on the plot and enable the edition and report the position. So, you can get the coordination of the edited circle by event_data. The report coordination is a named list. Observe the change of coordination and update the grey dots. And also update the coordination of the overlay circle objects. I also fixed the axes ranges, so you can see the plot difference after moving the circles.
That's nothing short of incredible, thank you so much!! I'll try to give you credit if a good opportunity arises.
If you could explain why all the changes were necessary in more detail that would be awesome because I don't really understand them, but if not, at least you solved my problem.
I will be developing this more and want to understand the mechanics so that I can avoid the same getting stuck in future.
@Rankineplant. In my code, I define two reactive values circle1 and circle2 to store the coordinate of the two shapes with initiate coordinate.
Because setting the shapePosition = TRUE, the coordinate of the shapes will be returned with event_data("plotly_relayout"). The return values will be a named list. The names will be shapes[0].xanchor and shapes[0].yanchor for the first shape and [1] for the second shape. So, we can update the x, y coordinate of the circle1 and circle2. And use circle1 and circle2 to update the circles and layout again on the plot. X and FillinYs is also updated with circle1 and circle2 for the coordinates of the grey dots.
Hope I can make myself clear.