问题
The given code creates a simple scatterPlot. I wish to click on the plot and move it in any direction that I want to, basically the span functionality. Attached the snapshot for references.Please help and thanks.
## app.R ##
library(shiny)
library(shinydashboard)
library(bupaR)
library(edeaR)
library(eventdataR)
library(processmapR)
library(processmonitR)
library(xesreadR)
library(lubridate)
library(dplyr)
library(knitr)
library(XML)
library(xml2)
library(data.table)
library(ggplot2)
library(ggthemes)
library(glue)
library(tibble)
library(miniUI)
library(tidyr)
library(shinyTime)
library(petrinetR)
library(magrittr)
library(shinyWidgets)
library(DiagrammeR)
ui <- dashboardPage(
dashboardHeader(title = "Zoom and Reset Dashboard",titleWidth = 290),
dashboardSidebar(
width = 0
),
dashboardBody(
# Creation of tabs and tabsetPanel
tabsetPanel(type = "tab",
tabPanel("Resource Dashboard",
fluidRow(column(10,
grVizOutput("res_freq_plot")))),
id= "tabselected"
)
))
server <- function(input, output)
{
output$res_freq_plot <- renderDiagrammeR(
{
patients %>% process_map()
}
)
}
shinyApp(ui, server)
回答1:
You can use plotly
## app.R ##
library(shiny)
library(plotly)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Zoom and Reset Dashboard",titleWidth = 290),
dashboardSidebar(
width = 0
),
dashboardBody(
# Creation of tabs and tabsetPanel
tabsetPanel(type = "tab",
tabPanel("Resource Dashboard",
fluidRow(column(10,
plotlyOutput("res_freq_plot")))),
id= "tabselected"
)
))
server <- function(input, output)
{
output$res_freq_plot <- renderPlotly(
{
plot_ly(iris, x= iris$Petal.Length, y = iris$Sepal.Length)
}
)
}
shinyApp(ui, server)
来源:https://stackoverflow.com/questions/46361495/implementing-span-to-click-on-plot-and-move-in-r-shiny