Сначала у меня есть код, который создает flexadashboard. Когда пользователь выбирает кнопку, относительное всплывающее сообщение активируется. Как вы можете видеть, все происходит внутри renderUI()
объекта. Проблема в том, что я не знаю, как создать такой же результат в блестящем приложении, поскольку я не могу использовать renderUI()
, как это внутри server.r
.
flex
---
title: "Single Column (Fill)"
output:
flexdashboard::flex_dashboard:
vertical_layout: fill
runtime: shiny
---
### Chart 1
```{r}
library(flexdashboard)
library(shiny)
library(shinyWidgets)
radioButtons("radio", label = h3("Radio buttons"),
choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3),
selected = 1)
renderUI({
if (input$radio==1) {
#paste("The following tickers already exist in the database:", bad_tickers, collapse = " ")
sendSweetAlert(session, title = "Bad tickers", text = paste("The following tickers already exist in the database:"))
} else if (input$radio==2) {
#paste("The following names already exist in the database:", bad_names, collapse = " ")
sendSweetAlert(session, title = "Bad Names", text = paste("The following names already exist in the database:"))
}
else {
sendSweetAlert(session, title = "Nice!", text = "Your tickers, names and weights have been saved. You'll see them appear as available funds if you refresh your browser.")
}
})
```
блестящий (не работает)
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
tags$h2("Sweet Alert examples"),
radioButtons("radio", label = h3("Radio buttons"),
choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3),
selected = 1)
)
server <- function(input, output, session) {
sendSweetAlert(
session = session,
title = "1",
text = "All in order",
type = "success"
)
sendSweetAlert(
session = session,
title = "2",
text = "It's broken...",
type = "error"
)
sendSweetAlert(
session = session,
title = "3",
text = "Non exist...",
type = "error"
)
}
shinyApp(ui, server)