Hello,
I am using R Shiny, and on my created app, between others, I am also having a plotly graph.
My problem is that I want to disable the automatic option of autoscaling when clicking on the image. That happens by double clicking when accessing through a computer, but only by simple clicking when accessing through a mobile phone (which is the main reason I need to do this change, the people that will use it, will often need to access it through their mobile phones).
I’ve found this documentation https://shiny.rstudio.com/reference/shiny/1.0.2/plotOutput.html but it does not seem to work with plotly. A reproducible example is given by
library(shiny)
library(RMySQL)
library(rsconnect)
library(plotly)
library(stats)
library(graphics)function(input, output) {
x <- seq(2006,2018)
y <- c(800,950,640,540,870,980,870,640,540,920,910,700,830)
z <- y + 30
qfit <- lm(y ~ x + I(x^2))output$plot <- renderPlotly ({
plot <- plot_ly() %>%
add_trace(x=x, y=y, type=“bar”, name=“value”) %>%
add_trace(x=x, y=z, type=“scatter”, mode=“markers”, yaxis = ‘y2’, name=‘new’) %>%
layout(legend = list(orientation = “h”, xanchor = “center”, x = 0.5),
xaxis = list(dtick=1),
yaxis = list(title = “Price”, side = ‘left’, range = c(500,1200), showgrid=FALSE),
yaxis2 = list(title = “Score”, side = ‘right’, overlaying = “y”, range = c(500,1200), showgrid=FALSE))
plot
})
}
(server.R file),
and
library(shiny)
library(RMySQL)
library(rsconnect)
library(plotly)
library(stats)
library(graphics)
library(shinythemes)renderUI(fluidPage(theme = shinytheme(“slate”),
titlePanel(div(HTML(""))),
mainPanel(
plotlyOutput(“plot”)
)))
(ui.R file).
This produces the graph, but if I replace
plotlyOutput(“plot”)
by
plotlyOutput(“plot”, dblclick = FALSE)
in order to disable the double click effect, I get the error:
Error : unused argument (dblclick = FALSE)
In case that has to do with the libraries masking functions between each other, the libraries I am using are: shiny, RMySQL, rsconnect, plotly, stats, graphics, plyr, DBI, sparklyr, graphics, shinythemes, stats although I doubt if that’s the case.
Can anyone help me on that?
I would appreciate it!
Thank you anyway,
Giannis