forked from daattali/advanced-shiny
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.R
39 lines (34 loc) · 707 Bytes
/
app.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
library(shiny)
mycss <- "
#plot-container {
position: relative;
}
#loading-spinner {
position: absolute;
left: 50%;
top: 50%;
z-index: -1;
margin-top: -33px; /* half of the spinner's height */
margin-left: -33px; /* half of the spinner's width */
}
#plot.recalculating {
z-index: -2;
}
"
ui <- fluidPage(
tags$head(tags$style(HTML(mycss))),
actionButton("btn", "Plot (takes 2 seconds)"),
div(id = "plot-container",
tags$img(src = "spinner.gif",
id = "loading-spinner"),
plotOutput("plot")
)
)
server <- function(input, output, session) {
output$plot <- renderPlot({
input$btn
Sys.sleep(2)
plot(rnorm(50))
})
}
shinyApp(ui, server)