【问题标题】:R Shiny vertical slider but mouse dragging horizontallyR 闪亮的垂直滑块,但鼠标水平拖动
【发布时间】:2019-04-07 03:53:21
【问题描述】:

我在寻找在 R Shiny 应用程序中制作垂直滑块的方法时遇到了一些未解决的问题,将其放在我的一个绘图旁边,以便用户可以在绘图中“移动水平线”滑块的范围与绘图的 y 轴相同。

我设法使滑块垂直,但它仍然希望鼠标水平拖动。任何人都知道如何用css攻击这个来旋转拖动动作?

      library(shiny)

  ui  <- fluidPage(
  fluidRow(
    column(3, 
 sliderInput(inputId = 'myslider1', label = 'Change vertical', min = -5, max = 6.3, step = 0.1, value = -6)
    ),
  column(3, 
     sliderInput(inputId = 'myslider2', label = 'Change horizontal', min = -5, max = 6.3, step = 0.1, value = 0)
  ), style = "margin-top:200px"
  ),

  tags$style(HTML(".js-irs-0 {  transform: rotateZ(270deg)}")),

  tags$style(HTML(".js-irs-0 .irs-bar-edge, .js-irs-0 .irs-bar {background: yellow}"))

  )

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


  }


  shinyApp(ui = ui, server = server)

【问题讨论】:

  • 或许可以试试.irs-slider single
  • 我试过了,比如 tags$style(HTML(".js-irs-0 .irs-slider single {transform: rotate(270deg)}")) 和其他各种但没有运气跨度>

标签: css r shiny rotation


【解决方案1】:

shinyWidgets 包中的这个函数 noUiSliderInput() 可以满足您的需要。

请看下面的例子:

if (interactive()) {

### examples ----

# see ?demoNoUiSlider
demoNoUiSlider("more")


###  basic usage ----

library( shiny )
library( shinyWidgets )


ui <- fluidPage(

  tags$br(),

  noUiSliderInput(
    inputId = "noui1",
    min = 0, max = 100,
    value = 20
  ),
  verbatimTextOutput(outputId = "res1"),

  tags$br(),

  noUiSliderInput(
    inputId = "noui2", label = "Slider vertical:",
    min = 0, max = 1000, step = 50,
    value = c(100, 400), margin = 100,
    orientation = "vertical",
    width = "100px", height = "300px"
  ),
  verbatimTextOutput(outputId = "res2")

)

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

  output$res1 <- renderPrint(input$noui1)
  output$res2 <- renderPrint(input$noui2)

}

shinyApp(ui, server)

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-25
    • 2016-10-07
    • 1970-01-01
    • 1970-01-01
    • 2018-05-10
    • 1970-01-01
    • 2015-01-06
    相关资源
    最近更新 更多