useAutoColor | R Documentation |
This piece of code is necessary so that plots get the good background color, automatically. It requires the use of the thematic package and shiny dev.
useAutoColor(input, output, session = shiny::getDefaultReactiveDomain())
input |
Shiny input object. |
output |
Shiny output object. |
session |
Shiny session object. |
An observer telling Shiny to update the current theme. It has to be inserted at the top of the main server function.
if (interactive()) {
library(shiny)
library(bs4Dash)
library(thematic)
thematic_shiny()
shinyApp(
ui = dashboardPage(
header = dashboardHeader(
title = bs4DashBrand(
title = "My dashboard",
color = "primary",
href = "https://adminlte.io/themes/v3",
image = "https://adminlte.io/themes/v3/dist/img/AdminLTELogo.png"
)
),
sidebar = dashboardSidebar(),
body = dashboardBody(
sliderInput("obs", "Number of observations:",
min = 0, max = 1000, value = 500
),
plotOutput("distPlot")
),
controlbar = dashboardControlbar(),
title = "DashboardPage"
),
server = function(input, output, session) {
useAutoColor()
output$distPlot <- renderPlot({
hist(rnorm(input$obs))
})
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.