Shiny - Dynamically add an annotation when user clicks on a point of a plotted line (dygraph or plotly)
Hello all,
I'm using dygraph on a Shiny App.
I want the user add dynamically an annotation on a plotted line when he clicks on it.
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
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| 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 in advance
Johnny