Shiny: أشرطة التقدم لوقت غير محدد

تم إنشاؤها على ٧ أكتوبر ٢٠١٤  ·  3تعليقات  ·  مصدر: rstudio/shiny

في بعض الأحيان لا توجد طريقة لتقدير وقت التنفيذ. بالنسبة لهذه الحالات ، قد يكون من المفيد أن يكون لديك إما مؤشر تقدم شعاعي أو شريط متحرك.
https://groups.google.com/d/msg/shiny-discuss/a3TcQ2C_hS0/3H4zocpRD0AJ

book

التعليق الأكثر فائدة

الاحتمال الآخر هو ببساطة جعل الخطوط أكثر وضوحًا وتعيين قيمة التقدم على 1:

server <- function(input, output) {
  output$plot <- renderPlot({
    input$goPlot # Re-run when button is clicked

    dat <- data.frame(x = rnorm(10), y = rnorm(10))

    withProgress(message = 'Making plot', value = 1, {
      Sys.sleep(20)
    })

    plot(dat$x, dat$y)
  })
}

ui <- shinyUI(basicPage(
  tags$head(tags$style(HTML("
    .progress-striped .bar {
      background-color: #149bdf;
      background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.6)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.6)), color-stop(0.75, rgba(255, 255, 255, 0.6)), color-stop(0.75, transparent), to(transparent));
      background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.6) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0.6) 75%, transparent 75%, transparent);
      background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.6) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0.6) 75%, transparent 75%, transparent);
      background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.6) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0.6) 75%, transparent 75%, transparent);
      background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.6) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0.6) 75%, transparent 75%, transparent);
      -webkit-background-size: 40px 40px;
         -moz-background-size: 40px 40px;
           -o-background-size: 40px 40px;
              background-size: 40px 40px;
    }
  "))),
  plotOutput('plot', width = "300px", height = "300px"),
  actionButton('goPlot', 'Go plot')
))

shinyApp(ui = ui, server = server)

ال 3 كومينتر

الاحتمال الآخر هو ببساطة جعل الخطوط أكثر وضوحًا وتعيين قيمة التقدم على 1:

server <- function(input, output) {
  output$plot <- renderPlot({
    input$goPlot # Re-run when button is clicked

    dat <- data.frame(x = rnorm(10), y = rnorm(10))

    withProgress(message = 'Making plot', value = 1, {
      Sys.sleep(20)
    })

    plot(dat$x, dat$y)
  })
}

ui <- shinyUI(basicPage(
  tags$head(tags$style(HTML("
    .progress-striped .bar {
      background-color: #149bdf;
      background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.6)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.6)), color-stop(0.75, rgba(255, 255, 255, 0.6)), color-stop(0.75, transparent), to(transparent));
      background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.6) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0.6) 75%, transparent 75%, transparent);
      background-image: -moz-linear-gradient(45deg, rgba(255, 255, 255, 0.6) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0.6) 75%, transparent 75%, transparent);
      background-image: -o-linear-gradient(45deg, rgba(255, 255, 255, 0.6) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0.6) 75%, transparent 75%, transparent);
      background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.6) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.6) 50%, rgba(255, 255, 255, 0.6) 75%, transparent 75%, transparent);
      -webkit-background-size: 40px 40px;
         -moz-background-size: 40px 40px;
           -o-background-size: 40px 40px;
              background-size: 40px 40px;
    }
  "))),
  plotOutput('plot', width = "300px", height = "300px"),
  actionButton('goPlot', 'Go plot')
))

shinyApp(ui = ui, server = server)

لقد حاولت أخذ الاقتراحات أعلاه ... لكن لا يبدو أنها تعمل ...

يرجى الاطلاع أدناه على محاولتي ، سيكون موضع تقدير كبير أي مساعدة.

http://stackoverflow.com/questions/38339593/shiny-loading-bar-for-htmlwidgets

هل من الممكن أيضًا استخدام شيء مثل هذا؟ ...

https://gist.github.com/eesur/cf81a5ea738f85732707

أعتقد أنه يمكنك استخدام https://getbootstrap.com/docs/3.4/components/#progress -animated.

اقترح @ jcheng5 تنشيط "الوضع غير المحدد" بتعيين value = NA . ولكن نظرًا لأن هذا يسمى "رسوم متحركة" ، فقد يكون من الأكثر مرونة إضافة معلمة animated ، وبالتالي يمكنك عمل withProgress(..., value = 1, animate = TRUE)

هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات