useAutoColor: Plot auto-color module

View source: R/auto-color.R

useAutoColorR Documentation

Plot auto-color module

Description

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.

Usage

useAutoColor(input, output, session = shiny::getDefaultReactiveDomain())

Arguments

input

Shiny input object.

output

Shiny output object.

session

Shiny session object.

Value

An observer telling Shiny to update the current theme. It has to be inserted at the top of the main server function.

Examples

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))
      })
    }
  )
}

bs4Dash documentation built on Sept. 11, 2024, 8:46 p.m.