Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Functionality to change color of line with click

Hello, I’m wondering - is it possible to change the colour of a line dynamically (ie. once clicked)?

I have set up a plot:

p2<-plot_ly(dt_calculate_subset_Freqvsiddq(),x=~get(input$Options_X), y=~get(input$Options_Y), name=‘speed’, type=‘scatter’, mode=‘markers+lines’, source=‘viewDataPlt1’) %>%

I’m using the “source” parameter and then using an output:

output$viewData<-renderPrint({
eventdata <- event_data(“plotly_click”,source=“viewDataPlt1”)
valOut<-eventdata$curveNumber
valOut
})

I can obtain the curveNumber for instance, but is there any way to manipulate that specific curve with that information? It seems like the curveNumber is a good method of doing this, since it is a distinct number for every curve on the plot.

Thanks!

Prateek

Hi @prateek.mohan1

perhaps these docs will be of interest:

coupled events https://plot.ly/r/shiny-coupled-events/
plotlyProxy https://plot.ly/r/plotlyproxy/#code

Cheers,

Thanks bcd! Yeah, these helped me tie together the functionality I needed.