链接到一个闪亮的应用程序的选项卡或面板 [英] Linking to a tab or panel of a shiny app

查看:125
本文介绍了链接到一个闪亮的应用程序的选项卡或面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何设法将指定的闪亮部分链接到位于其他选项卡/面板上的部分?

更新



我在下面起草的解决方案适用于链接到选项卡/面板的显式情况(这就是我所要求的)。



然而,我也有兴趣了解链接闪亮应用的各个部分的更多通用方法。



示例



我想从面板A链接到面板B,但我不太确定我需要指定什么作为点击面板A中的动作链接时的动作。

#tab-4527-2 传来从调查 ui 的HTML输出,但我刚看到每次重新启动应用程序时这些值都会更改。

 库(闪亮)

#UI -------------------------- -------------------------------------------
$ b $ (
tabPanel(
A,
p(),
actionLink(link_to_tabpanel_b,链接到面板B)) )
),
tabPanel(
B,
h3(某些信息),
标签$ li(Item 1),
标签$ li(Item 2)




#服务器------- -------------------------------------------------- ---------

服务器< - 函数(输入,输出,会话){
observeEvent(输入$ link_to_tabpanel_b,{
tags $ a(href =#tab-4527-2)
})
}

shinyApp(ui,server)


解决方案

我们刚刚发布了路由库,这使得Shiny易于链接。这是它的外观。

  make_router(
route(< your_app_url> / main,
route(< your_app_url> / other,other_page_shiny_ui)

更多信息可在此博客文章

How do I manage to link from a given shiny part to parts that are located on other tabs/panels?

Update

The solution I drafted below works for the explicit case of linking to tabs/panels (and that's what I asked for).

However, I'd be interested to also know about more generic ways of linking parts of a shiny app.

Example

I'd like to link from panel A to panel B, but I'm not quite sure what I need to specify as an action when the action link in panel A is clicked.

The value #tab-4527-2 came from investigating the HTML output of ui, but I just saw that those values change each time I restart the app.

library(shiny)

# UI ---------------------------------------------------------------------

ui <- fluidPage(
  tabsetPanel(
    tabPanel(
      "A",
      p(),
      actionLink("link_to_tabpanel_b", "Link to panel B")
    ),
    tabPanel(
      "B",
      h3("Some information"),
      tags$li("Item 1"),
      tags$li("Item 2")
    )
  )
)

# Server ------------------------------------------------------------------

server <- function(input, output, session) {
  observeEvent(input$link_to_tabpanel_b, {
    tags$a(href = "#tab-4527-2")
  })
}

shinyApp(ui, server)

解决方案

We have just released a routing library, which makes linking in Shiny easy. Here's how it looks like in a nutshell.

make_router(
   route("<your_app_url>/main",  main_page_shiny_ui),
   route("<your_app_url>/other", other_page_shiny_ui)
)

More information can be found in this blog post.

这篇关于链接到一个闪亮的应用程序的选项卡或面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆