R: adjusting legend labels to the selected (gg)plotly output

I am using ggplotly object to visualize a scatterplot in a shiny dashboard. I have a plot colored using the values of a column. However, when I want to look at a certain part of the plot, I zoom in to know more about the points. Then the legend labels should adjust according to the points present in the visible window or selected/chosen region.

How to adjust/update the labels to the selected region? Should this handled using shiny reactive features?