Dynamically add annotation on a dygraph plot in a shiny app when click on a plotted line

21 views
Skip to first unread message

Johnny Jackson

unread,
Apr 9, 2020, 9:08:34 AM4/9/20
to dygraphs-users
 Hello all,


I'm using dygraph package on a Shiny App.


I would like the user add dynamically an annotation on a plotted line when he clicks on one of its point.

I also want him able to edit this annotation.


I spent a lot of time trying but I can't find a way to do it in a ShinyApp. Could you help me ?


Here a basic application involving a dygraph


library(shiny)
library
(dygraphs)

X
<- c(1,2,3,4,5,6,7,8,9,10)
Y
<-c(100,200,250,267,234,88,78,90,15,32)
data
<- data.frame(X,Y)

 ui
<- fluidPage(
        titlePanel
("Test"),
        sidebarLayout
(
                     sidebarPanel
( ),
                     mainPanel
(
                               dygraphOutput
("plot")
                               
)
                     
)
                 
)


server
<- function(input, output) {

         output$plot
<- renderDygraph({
                                       p
<- dygraph(data)%>% dyRangeSelector()
                                     
})

}


shinyApp
(ui = ui, server = server)`

I feel the answer is somewhere around dyAnnotation() or dyCallbacks with a pointClickCallback = but I can't managed it with JS code.


If someone know how to solve it with another library (like plotly) feel free to tell me how.


Thanks a lot


Johnny

Reply all
Reply to author
Forward
0 new messages