从外部 link 闪亮导航到特定选项卡
navigating to specific tab from external link shiny
我正在尝试向外部应用程序授予对我闪亮仪表板的特定视图的访问权限。基本上,我想给他们一个带有过滤器参数的 url link,这样当他们单击 link 时,我闪亮的仪表板会在应用过滤器的特定视图上打开。我在 SO 上看到了一些关于相同内容的其他帖子
我尝试使用代码找出解决方案,但未能成功。这就是我目前拥有的,我想要的是
http://127.0.0.1:7687/?url=%22Plot%202%22&species=%22setosa%22
这应该会打开仪表盘的 Plot 2 选项卡并应用相关过滤器。在这方面的任何帮助都会很棒。谢谢!
library(shiny)
library(DT)
# Define UI for application that draws a histogram
ui <- navbarPage(title = "Navigate", id = 'nav',
# Application title
tabPanel("Plot",
plotOutput("distPlot")
),
tabPanel("Plot 2",
selectInput("species", "Select Species", choices = c("setosa", "virginica"),
multiple = T, selected = NULL),
dataTableOutput("tbl1")
)
)
# Define server logic required to draw a histogram
server <- function(input, output, session) {
observe({
query <- parseQueryString(session$clientData$url_search)
if(!is.null(query$url)) {
url <- strsplit(query$url,"/")[[1]]
updateTabsetPanel(session, 'nav', url)
}
})
output$distPlot <- renderPlot({
hist(rnorm(100), col = 'darkgray', border = 'white')
})
output$tbl1 <- renderDataTable({
tmp <- iris
if(!is.null(input$species))
tmp <- iris[which(iris$Species %in% input$species), ]
datatable(tmp)
})
}
# Run the application
shinyApp(ui = ui, server = server)
你的观察应该是这样的:
observe({
query <- parseQueryString(session$clientData$url_search)
if(!is.null(query$url)) {
url <- strsplit(query$url,"\"")[[1]][2]
species <- strsplit(query$species, "\"")[[1]][2]
updateTabsetPanel(session, 'nav', url)
updateSelectInput(session, 'species',selected = species)
}
})
我正在尝试向外部应用程序授予对我闪亮仪表板的特定视图的访问权限。基本上,我想给他们一个带有过滤器参数的 url link,这样当他们单击 link 时,我闪亮的仪表板会在应用过滤器的特定视图上打开。我在 SO 上看到了一些关于相同内容的其他帖子
我尝试使用代码找出解决方案,但未能成功。这就是我目前拥有的,我想要的是 http://127.0.0.1:7687/?url=%22Plot%202%22&species=%22setosa%22
这应该会打开仪表盘的 Plot 2 选项卡并应用相关过滤器。在这方面的任何帮助都会很棒。谢谢!
library(shiny)
library(DT)
# Define UI for application that draws a histogram
ui <- navbarPage(title = "Navigate", id = 'nav',
# Application title
tabPanel("Plot",
plotOutput("distPlot")
),
tabPanel("Plot 2",
selectInput("species", "Select Species", choices = c("setosa", "virginica"),
multiple = T, selected = NULL),
dataTableOutput("tbl1")
)
)
# Define server logic required to draw a histogram
server <- function(input, output, session) {
observe({
query <- parseQueryString(session$clientData$url_search)
if(!is.null(query$url)) {
url <- strsplit(query$url,"/")[[1]]
updateTabsetPanel(session, 'nav', url)
}
})
output$distPlot <- renderPlot({
hist(rnorm(100), col = 'darkgray', border = 'white')
})
output$tbl1 <- renderDataTable({
tmp <- iris
if(!is.null(input$species))
tmp <- iris[which(iris$Species %in% input$species), ]
datatable(tmp)
})
}
# Run the application
shinyApp(ui = ui, server = server)
你的观察应该是这样的:
observe({
query <- parseQueryString(session$clientData$url_search)
if(!is.null(query$url)) {
url <- strsplit(query$url,"\"")[[1]][2]
species <- strsplit(query$species, "\"")[[1]][2]
updateTabsetPanel(session, 'nav', url)
updateSelectInput(session, 'species',selected = species)
}
})