Implementing span to click on plot and move in R shiny

允我心安 提交于 2019-12-11 15:26:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!