【问题标题】:RShiny-CSS reactive messageR Shiny-CSS 反应式按摩
【发布时间】:2016-02-26 22:06:49
【问题描述】:

我使用 Shiny 有一段时间了,最​​近开始使用 CSS 自定义我的应用程序,这很酷。当指针越过特定元素时,我设法显示一个消息框,但现在我想显示一个变量。例如,在以下应用程序中,当鼠标移到滑块按钮上时,在消息框内我想计算滑块值,即“input$test”:

#### ui.R

shinyUI(fluidPage(
tags$head(tags$style(HTML('

                        .irs.js-irs-0.irs-with-grid .irs-slider.single:hover:after {
                        content: "SLIDER VALUE HERE";
                        background: #333;
                        background: rgba(0,0,0,.8);
                        border-radius: 5px;
                        bottom: 26px;
                        color: #fff;
                        left: 20%;
                        padding: 5px 15px;
                        position: absolute;
                        width: 220px;
                        text-align: center;
                        }

                        '))),

sliderInput("test", "TEST:", 
          min=0, max=1000, value=500)
))

#### server.R

library(shiny)
shinyServer(function(input, output) {
})

感谢您的帮助。

【问题讨论】:

    标签: css r shiny


    【解决方案1】:

    这行得通,希望对其他人有所帮助:

    #### ui.R
    
    shinyUI(fluidPage(
    
    
      uiOutput("htmltest"),
    
      sliderInput("test", "TEST:", 
              min=0, max=1000, value=500)
    
    ))
    
    #### server.R
    
    shinyServer(function(input, output) {
    
    
    output$htmltest <- renderUI({
      txtx=paste('.irs.js-irs-0.irs-with-grid .irs-slider.single:hover:after {
                            content: "',input$test,'";
             background: #333;
             background: rgba(0,0,0,.8);
             border-radius: 5px;
             bottom: 26px;
             color: #fff;
             left: 20%;
             padding: 5px 15px;
             position: absolute;
             width: 220px;
             text-align: center;
    }',sep="")
    
      tags$head(tags$style(HTML(txtx)))
    })
    
    })
    

    【讨论】:

      猜你喜欢
      • 2018-10-11
      • 1970-01-01
      • 1970-01-01
      • 2018-02-13
      • 2017-01-17
      • 2014-12-14
      • 2017-10-19
      • 2016-05-26
      • 2021-05-21
      相关资源
      最近更新 更多