Можно ли использовать как абсолютную панель, так и слайдерВвод в одном и том же ui.R (блестящем)?

Это мой ui.R. Это пример, приведенный в учебнике Shiny. Я только что отредактировал его.

library(shiny)
library(markdown)
# Define UI for application that draws a histogram
shinyUI(fluidPage(

  # Application title
  titlePanel("Hello Shiny!"),

  # Sidebar with a slider input for the number of bins
  sidebarLayout(
    sidebarPanel(
      sliderInput("bins",
                  "Number of bins:",
                  min = 1,
                  max = 50,
                  value = 30)
    ),

    # Show a plot of the generated distribution
    mainPanel(
      plotOutput("distPlot"),
absolutePanel(
  bottom = 0, left=420,  width = 800,
    draggable = TRUE,
    wellPanel(
em("This panel can be moved")      

      )
)    

  ))
))

и мой server. R

library(shiny)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
  # Expression that generates a histogram. The expression is
  # wrapped in a call to renderPlot to indicate that:
  #
  #  1) It is "reactive" and therefore should be automatically
  #     re-executed when inputs change
  #  2) Its output type is a plot
  output$distPlot <- renderPlot({
    x    <- faithful[, 2]  # Old Faithful Geyser data
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    # draw the histogram with the specified number of bins
    hist(x, breaks = bins, col = 'darkgray', border = 'white')
  })
})**

В этом случае sliderInput не работает. Если я удалю абсолютную панель, sliderInput в порядке. В чем может быть проблема?
Большое спасибо


person ramesh    schedule 03.04.2014    source источник
comment
у вас опечатка в аргументе absolutePanel: draggaInputble = TRUE,   -  person Fadeway    schedule 03.04.2014
comment
@Fadeaway, мне очень жаль, я допустил ошибку при копировании и вставке сюда. Теперь я отредактировал его.   -  person ramesh    schedule 03.04.2014
comment
У меня та же проблема: кажется, что установка draggable = FALSE в вызове absolutePanel решает проблему с ползунком, но очевидно, что они должны сосуществовать. Это также работает, если вы переместите ползунок в absolutePanel, поэтому я полагаю, что текущая проблема, скорее всего, просто ошибка, которую нужно исправить. Вы можете изменить заголовок своего вопроса, чтобы отразить это, или сообщить о нем как об ошибке на сайте github: https://github.com/rstudio/shiny/issues   -  person theEricStone    schedule 29.04.2014


Ответы (1)


absolutePanel использует библиотеку javascript jqueryui. Есть свой слайдер. Это приводит к конфликту с sliderInput, который использует библиотеку jslider. Вы можете увидеть это следующим образом:

library(shiny)
runApp(
  list(ui = fluidPage(
    titlePanel("Hello Shiny!"),
    sidebarLayout(
      sidebarPanel(
        sliderInput("bins",
                    "Number of bins:",
                    min = 1,
                    max = 50,
                    value = 30)
      ),
      mainPanel(
        plotOutput("distPlot")
        , tags$head(tags$script(src = "shared/jqueryui/1.10.3/jquery-ui.min.js"))

      )
    )
  ),
  server = function(input, output) {
    output$distPlot <- renderPlot({
      x    <- faithful[, 2]  # Old Faithful Geyser data
      bins <- seq(min(x), max(x), length.out = input$bins + 1)
      hist(x, breaks = bins, col = 'darkgray', border = 'white')
    })
  }
  )
)

РЕДАКТИРОВАТЬ: это было исправлено в последней версии Shiny для разработчиков. Компонент слайдера был удален из пакета jqueryui inc. https://github.com/rstudio/shiny/commit/7e12a281f51e047336ba2c501fcac43af5253225

person jdharrison    schedule 05.05.2014