I have a R-Shiny application with a plot that implements interactive actions: click, hovering (hovering is passing the mouse over the plot, which can be detected by shiny).
While I can't solve the question completely, maybe a dirty workaround could also have some value to you. Or someone else can build on that answer.
I could reproduce the error that the clicks on the plot are not captured on mobile. But I noticed that I can add additional clickevents with javascript/shinyjs.
One way would be:
onevent(event = "click", id = "plot", function(e){
global$clickx = c(global$clickx, e$pageX - 88)
global$clicky = c(global$clicky, 540 - e$pageY)
})
It has a few drawbacks:
I ran a bit out of time after a few hours, one can for sure improve it, but maybe its of interest for you anyway.
Test here: (link might change within next weeks)
http://ec2-3-121-215-255.eu-central-1.compute.amazonaws.com/shiny/rstudio/sample-apps/mobile/
Reproducible code: (tested on smartphone: Mi A2)
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
h4("Click on plot to start drawing, click again to pause"),
plotOutput(outputId = "plot", width = "500px", height = "500px")
)
server <- function(input, output, session) {
onevent(event = "click", id = "plot", function(e){
global$clickx = c(global$clickx, e$pageX - 88)
global$clicky = c(global$clicky, 540 - e$pageY)
})
global <- reactiveValues(clickx = NULL, clicky = NULL)
output$plot= renderPlot({
plot(x = NULL, y = NULL, xlim=c(0, 440), ylim=c(0, 440), ylab="y", xlab="x", type="l")
len <- length(global$clickx)
lines(x = global$clickx, y = global$clicky, type = "p")
if(len > 1){
for(nr in 2:len){
lines(x = global$clickx[(nr - 1):nr], y = global$clicky[(nr - 1):nr], type = "l")
}
}
})
}
shinyApp(ui, server)