页面打开时动画-R Shiny slideInput按钮->动画

您好,以下是我的Shiny应用中UI部分开头的代码:

shinyUI(navbarPage("Boston Food Inspections", id="nav",
  tabPanel("Interactive map",
           div(class="outer",

               tags$head(
               includeCSS("styles.css")
               ),
           leafletOutput("map", width="100%", height = "100%"),

           absolutePanel(id ="controls", class ="panel panel-default", fixed=TRUE,
                         draggable=TRUE, top=60, left='auto', right=20, bottom='auto',
                         width=300, height='auto',
                         checkboxGroupInput("status", h4("Business License Status"), bstatus,
                                            selected = "Active"),
                         checkboxGroupInput("violations", h4("Violation"), violationType, 
                                            selected="Rodents"),
                         sliderInput('period', h4("Select Time Period"),
                                     min = 2008,
                                     max = 2015,
                                     value = c(2008,2008),
                                     sep="", step=1, ticks=FALSE,animate=animationOptions(loop=T)), round=TRUE
                        )
           )
  ),

现在,我的动画选项指定滑块将具有“播放/暂停”按钮.但是,sliderInput仅在用户打开应用程序时才开始播放.我想知道是否有人知道一种简单的方法来更改javascript,以便只要页面加载就可以开始SliderInput的播放?

谢谢.

解决方法:

使用jQuery加载页面后,您可以单击该按钮.这是一个例子:

server <- function(input, output) {
}

ui <- fluidPage(
        sliderInput("obs", "Number of observations:",
                    min = 10, max = 500, value = 100,
                    animate=T),
        tags$script("$(document).ready(function(){
                        setTimeout(function() {$('.slider-animate-button').click()},10);
                    });")
                )

shinyApp(ui = ui, server = server)

tags $script部分单击该按钮.我添加了setTimeout以将单击延迟10毫秒,以等待附加单击处理程序.

上一篇:r shiny app learning tutorial a sliderinput


下一篇:qiime2 view镜像网站等你来用