2014-09-23 3 views
8

참고 : 반짝이는 googlegroups 및 여기에있는이 개체에 대한 거의 모든 토론을 읽었습니다.빛나는 앱 사용 중 표시

빛나는 서버가 사용 중임을 나타내는 표시기가 필요합니다. 나는 반짝이는 인큐베이터를 시험해 보았지만, 문제는 진행률 표시 줄에 최대 값을 설정할 수 없다는 것입니다. 나는 다음과 같은 것을 원하지 않는다 : http://shiny.rstudio.com/gallery/progress-example.html 내가 필요한 것은 : 1- 표시가 바쁜 표시기 메시지와 바 (즉, 간단한 애니메이션 바, 채움 막대를 표시 할 필요가 없음)가있는 한 서버는 을 계산 중입니다.보고있는 탭에 상관없이 2가 표시됩니다.

감사

+0

링크가 죽었습니다 ... –

답변

8

(관련 탭하지만, 탭 세트 위에뿐만 아니라) 나뿐만 아니라이 찾고 있었어요. 대부분의 사람들은 조건부 패널과 같이 제안한다

conditionalPanel(
      condition="!($('html').hasClass('shiny-busy'))", 
      img(src="images/busy.gif") 
) 

당신은 항상 당신의 ui.R이 같은 조건 처리 (어쩌면 더 많은 물건에 따라) 자신에게 더 많은 제어를 제공하고 만들 수 있습니다

div(class = "busy", 
    p("Calculation in progress.."), 
    img(src="images/busy.gif") 
) 

일부 자바 스크립트가 DIV의 표시 및 숨기기 처리 여기서 몇 가지 추가 CSS로

setInterval(function(){ 
    if ($('html').attr('class')=='shiny-busy') { 
    $('div.busy').show() 
    } else { 
    $('div.busy').hide() 
    } 
},100) 

을 당신은 당신의 애니메이션 바쁜 이미지가 고정 된 위치보다 어디를 얻을 수 있는지 확인 할 수 그것은 항상 보일 것입니다.

"반짝 반짝 빛나는"상태가 다소 부정확하고 신뢰할 수 없다는 것을 발견했습니다. div가 초 단위로 표시되고 계산이 진행되는 동안 사라집니다. 더러운 솔루션을 발견했습니다. 적어도 내 애플 리케이션에서 그 문제를 해결하기 위해. 시험해보고 자유롭게 사용해보십시오. 누군가가 어떻게 그리고 왜 이것이 문제를 해결하는지에 대한 통찰력을 줄 수 있습니다. (또는 계산이 갈 다른 출력 기능), 당신이를 재설정 이러한 반응 값을 사용하여 renderPlot 기능에 다음

shinyServer(function(input, output, session) { 

    # Reactive Value to reset UI, see render functions for more documentation 
    uiState <- reactiveValues() 
    uiState$readyFlag <- 0 
    uiState$readyCheck <- 0 

: 당신의 server.R에서

두 reactiveValues를 추가해야합니다 기능 :

output$plot<- renderPlot({ 

    if (is.null(input$file)){ 
     return() 
    } 
    if(input$get == 0){ 
     return() 
    } 

    uiState$readyFlag 

    # DIRTY HACK: 
    # Everytime "Get Plot" is clicked we get into this function 
    # In order for the ui to be able show the 'busy' indicator we 
    # somehow need to abort this function and then of course seamlessly 
    # call it again. 
    # We do this by using a reactive value keeping track of the ui State: 
    # renderPlot is depending on 'readyFlag': if that gets changed somehow 
    # the reactive programming model will call renderPlot 
    # If readyFlag equals readyCheck we exit the function (= ui reset) but in the 
    # meantime we change the readyFlag, so the renderHeatMap function will 
    # immediatly be called again. At the end of the function we make sure 
    # readyCheck gets the same value so we are back to the original state 

    isolate({ 
     if (uiState$readyFlag == uiState$readyCheck) { 
      uiState$readyFlag <- uiState$readyFlag+1 
      return(NULL) 
     } 
    }) 

    isolate({plot <- ...}) 

    # Here we make sure readyCheck equals readyFlag once again 
    uiState$readyCheck <- uiState$readyFlag 

    return(plot) 
}) 
+0

감사합니다. 나는 그것을 시도하고 그 결과를 알려 줄 것이다. –

0

바쁜 사업부는 명백한 계산 (이것은 이전 버전에서 문제가 아니었다)에 않을 경우에도, 반짝의 최신 버전에 대한 분할 초 동안 나타납니다. 반짝 이는 짧은 시간 동안 바쁜 모드로 정기적으로있는 것 같습니다. 위의 설명을 보완하는 해결책으로 조건부 처리를 위해 shiny-busy html 클래스의 두 번째 지연된 유효성 검사를 추가로 포함 할 수 있습니다.

 if(($('html').attr('class')=='shiny-busy')){ 
       setTimeout(function() { 
       if ($('html').attr('class')=='shiny-busy') { 
        if($('#textit').html()!='Waiting...'){ 
         $('div.busy1').show() 
        } 
        if($('#textit').html()=='Waiting...'){ 
         $('div.busy2').show() 
        } 
       } 
       },1000) 
       } else { 
       $('div.busy1').hide() 
       $('div.busy2').hide() 
       } 
      },100) 
1

내가 (보여 반대 fadeIn()를 사용하여 발견) 완화하는 데 도움이 : 자바 스크립트 부분이 그런 일을 보일 것이다 (예는 반응 textit에 따라 두 개의 서로 다른 div.busy-상태에 대한 검사 포함) 이 깜박이는 occurence :

setInterval(function(){ 
        if ($('html').attr('class')=='shiny-busy') { 
          setTimeoutConst = setTimeout(function(){ 
           $('#loading-page').fadeIn(500); 
          }, delay); 
         } else { 
          clearTimeout(setTimeoutConst); 
          $('#loading-page').hide(); 
         } 
       },10)