【问题标题】:How to color the slider in shiny to the right of the value instead of to the left?如何在值的右侧而不是左侧为滑块着色?
【发布时间】:2018-04-28 13:51:33
【问题描述】:

我正在构建一个闪亮的应用程序,并使用与闪亮画廊 (http://shiny.rstudio.com/gallery/slider-bar-and-slider-range.html) 中显示的滑块非常相似的滑块。默认情况下,它在所选值的左侧显示为蓝色(在此示例中为 0 到 50)。有没有办法让它在所选值的右侧着色:e.i.从50到100?

我想这样做的原因是,用户应该将其读取为“从阈值到最大值的所有值”,因此从最小值到阈值的着色会产生误导。

有人对此有想法吗? 玛丽亚

【问题讨论】:

    标签: r shiny slider


    【解决方案1】:

    可能有更好的方法,但这里有一个快速的 css 选项:

    library(shiny)
    shinyApp( 
      ui = fluidPage(
    
        tags$head( tags$style( type = "text/css", '
          .irs-line-mid{
            background: #428bca ;
            border: 1px solid #428bca ;
          }
          .irs-line-right{
            background: #428bca ;
          }
          .irs-bar {
            background: linear-gradient(to bottom, #DDD -50%, #FFF 150%);
            border-top: 1px solid #CCC ;
            border-bottom: 1px solid #CCC ;
          }
          .irs-bar-edge {
            background: inherit ;
            border: inherit ;
          }
    
        ')), 
    
        sliderInput( "slider", label  = "Slider", min = 0, max = 100, value = 50)
      ), server = function(input,output){} 
    )
    

    【讨论】:

    • 我今天需要这个。谢谢。
    猜你喜欢
    • 2019-05-12
    • 1970-01-01
    • 2019-12-28
    • 2012-02-04
    • 2016-09-09
    • 2021-03-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多