使用ShinyBS在闪亮的反应性工具提示BS [英] reactive tooltipBS in shiny using ShinyBS

查看:83
本文介绍了使用ShinyBS在闪亮的反应性工具提示BS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在我的简单应用程序中使用shinyBS包.我想做的是根据每个radioButton来创建反应性的工具提示文本.

I try to use shinyBS package into my simple app. What I want to do is to create reactive tooltip text depends on each radioButton.

为了澄清我的问题,我在 HTML& JS .

In order to clarify my problem I wrote a simple code in HTML & JS.

我还找到了一个解决方案,它似乎可以解决我的问题,但实际上我认为它无法正常工作.是否可以使用shinyBS包来做到这一点?

I also found one solution which seemed to solve my issue, but actually I do not think it works properly. Is it possible to do it using shinyBS package?

我也想实现我的HTML&将JS代码转换为Shiny,但仍然无法正常工作.

I also want to implement my HTML & JS code into Shiny but still it does not work.

library(shiny)

yourStr <-   "$(document).ready(function(){
                      $('[id='radio_venue_1']').tooltip({
                                placement: 'right',
                                title: 'Button 1 Explanation',
                                trigger: 'hover'
                                });

                      $('[id='radio_venue_2']').tooltip({
                                placement: 'right',
                                title: 'Button 2 Explanation',
                                trigger: 'hover'
                                });

                      $('[id='radio_venue_3']').tooltip({
                                placement: 'right',
                                title: 'Button 3 Explanation',
                                trigger: 'hover'
                                });
                                });
"

ui <- shinyUI(

  fluidPage(
    fluidRow(
      column(3,
             HTML("<div class='container'><br>
                  <h1>Test</h1>
                  <div>
                  <label id='radio_venue_1'> 
                  <input type='radio' value='1' role='button'> button 1 
                  </label>
                  </div>
                  <div>
                  <label id='radio_venue_2'>
                  <input type='radio' value='2' role='button'> button 2
                  </label>
                  </div>
                  <div>
                  <label id='radio_venue_3'>
                  <input type='radio' value='3' role='button'> button 3
                  </label>
                  </div>
                  </div>")
      ), 
      column(9,
             'Plot')
      ),
  tags$script(HTML(yourStr))
    )
  )

server <- function(input, output, session) { 

}

shinyApp(ui = ui, server = server)

推荐答案

您绝对可以使用shinyBS

rm(list = ls())
library(shiny)
library(shinyBS)

ui <- shinyUI(
  fluidPage(
    fluidRow(
      column(3,
             HTML("<div class='container'><br>
                  <h1>Test</h1>
                  <div>
                  <label id='radio_venue_1'> 
                  <input type='radio' value='1' role='button'> button 1 
                  </label>
                  </div>
                  <div>
                  <label id='radio_venue_2'>
                  <input type='radio' value='2' role='button'> button 2
                  </label>
                  </div>
                  <div>
                  <label id='radio_venue_3'>
                  <input type='radio' value='3' role='button'> button 3
                  </label>
                  </div>
                  </div>")), 
      bsTooltip(id = "radio_venue_1", title = "Button 1 Explanation", placement = "right", trigger = "hover"),
      bsTooltip(id = "radio_venue_2", title = "Button 2 Explanation", placement = "right", trigger = "hover"),
      bsTooltip(id = "radio_venue_3", title = "Button 3 Explanation", placement = "right", trigger = "hover"),
      column(9,'Plot')
      )
    )
  )

server <- function(input, output, session) {}
shinyApp(ui = ui, server = server)

这篇关于使用ShinyBS在闪亮的反应性工具提示BS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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