Closed kueckelj closed 3 years ago
Hello Jan!
Ah yes I should include this example somewhere! You probably put add_busy_spinner
in dashboardHeader
? You should use it in sidebar or body. Here's an example :
library(shiny)
library(shinybusy)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Iris clustering"),
dashboardSidebar(),
dashboardBody(
add_busy_spinner(spin = "cube-grid", margins = c(0, 10), color = "#FFF"),
headerPanel('Iris k-means clustering'),
sidebarLayout(
sidebarPanel(
selectInput('xcol', 'X Variable', names(iris)),
selectInput('ycol', 'Y Variable', names(iris),
selected=names(iris)[[2]]),
numericInput('clusters', 'Cluster count', 3,
min = 1, max = 9),
actionButton("sleep", "Sleeeep")
),
mainPanel(
plotOutput('plot1')
)
)
),
title = "Dashboard example"
)
server <- function(input, output, session) {
# Combine the selected variables into a new data frame
selectedData <- reactive({
iris[, c(input$xcol, input$ycol)]
})
clusters <- reactive({
kmeans(selectedData(), input$clusters)
})
output$plot1 <- renderPlot({
palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
"#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))
par(mar = c(5.1, 4.1, 0, 1))
plot(selectedData(),
col = clusters()$cluster,
pch = 20, cex = 3)
points(clusters()$centers, pch = 4, cex = 4, lwd = 4)
})
observeEvent(input$sleep, {
Sys.sleep(5)
})
}
shinyApp(ui, server)
Victor
Exactly. As the vignette said “somewhere in your UI” I just tried a few random positions in the sidebar and the header but none of them worked. But yours – which was literally the only one I hadn’t tried, stupidme 😃 - does!! Thank you very much for the quick response!
Jan
Von: Victor Perrier notifications@github.com Gesendet: Dienstag, 18. Februar 2020 22:20 An: dreamRs/shinybusy shinybusy@noreply.github.com Cc: Kuecki95 jankueckelhaus@gmx.de; Author author@noreply.github.com Betreff: Re: [dreamRs/shinybusy] add_busy_spinner() for shinydashbaord (#5)
Hello Jan!
Ah yes I should include this example somewhere! You probably put add_busy_spinner in dashboardHeader ? You should use it in sidebar or body. Here's an example :
library(shiny) library(shinybusy) library(shinydashboard)
ui <- dashboardPage( dashboardHeader(title = "Iris clustering"), dashboardSidebar(), dashboardBody(
add_busy_spinner(spin = "cube-grid", margins = c(0, 10), color = "#FFF"),
headerPanel('Iris k-means clustering'),
sidebarLayout(
sidebarPanel(
selectInput('xcol', 'X Variable', names(iris)),
selectInput('ycol', 'Y Variable', names(iris),
selected=names(iris)[[2]]),
numericInput('clusters', 'Cluster count', 3,
min = 1, max = 9),
actionButton("sleep", "Sleeeep")
),
mainPanel(
plotOutput('plot1')
)
)
), title = "Dashboard example" )
server <- function(input, output, session) {
selectedData <- reactive({ iris[, c(input$xcol, input$ycol)] })
clusters <- reactive({ kmeans(selectedData(), input$clusters) })
output$plot1 <- renderPlot({ palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3", "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))
par(mar = c(5.1, 4.1, 0, 1))
plot(selectedData(),
col = clusters()$cluster,
pch = 20, cex = 3)
points(clusters()$centers, pch = 4, cex = 4, lwd = 4)
})
observeEvent(input$sleep, { Sys.sleep(5) })
}
shinyApp(ui, server)
Victor
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dreamRs/shinybusy/issues/5?email_source=notifications&email_token=ANTVJ77GGVDH5GPJLRHD7RLRDRGIVA5CNFSM4KXFLPZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMFCQMA#issuecomment-587868208 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ANTVJ73HG2UKBWYNH75E3K3RDRGIVANCNFSM4KXFLPZQ .
Hey, I'm using shinydashboard and I'd like to integrate a busy spinner in the top right corner - as you've shown in one of your examples. Would you mind sharing the code of your example where you add a busy_spinner to shinydashboard - so I know where to put the function in order to make it work? I don't know why but wherever I place the function I get an error message including " Expected an object with class 'shiny.tag'. "!
That'd be great!
Greetings
Jan