Add subtitle in shinydashboard title section - r

Is it possible to add a subtitle with smaller font size in shinydashboard title section under the main title?
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title="Dashboard"),
dashboardSidebar(),
dashboardBody()
)
server <- function(input, output) { }
shinyApp(ui, server)

Something like this would work:
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(
title= div(h3('Títutlo', style="margin: 0;"), h4('subtitulo', style="margin: 0;"))
),
dashboardSidebar(),
dashboardBody()
)
server <- function(input, output) { }
shinyApp(ui, server)

Related

Shiny seesion object is not found when trying to use shinyJS()

In the shiny app below Im trying to use shinyJS() to hide and display text but I get:
Error: shinyjs: could not find the Shiny session object. This usually happens when a shinyjs function is called from a context that wasn't set up by a Shiny session.
Do not bother that dataset does not exist its just an example
## app.R ##
library(shiny)
library(shinydashboard)
library(dplyr)
library(shinyjs)
ui <- dashboardPage(
dashboardHeader(title = "Biodiversity"),
dashboardSidebar(
actionButton("action","Submit")
),
dashboardBody(
useShinyjs(),
show(
div(id='text_div',
verbatimTextOutput("text")
)
),
uiOutput("help_text"),
plotlyOutput("plot")
)
)
server <- function(input, output) {
output$help_text <- renderUI({
HTML("<b>Click 'Show plot' to show the plot.</b>")
})
react<-eventReactive(input$action,{
hide("help_text")
omited <-subset(omited, omited$scientificName %in% isolate(input$sci)&omited$verbatimScientificName %in% isolate(input$ver))
})
}
shinyApp(ui = ui, server = server)
You can't use show() in the ui, these functions are used in the server. Remove that and it works. Sample:
## app.R ##
library(shiny)
library(shinydashboard)
library(dplyr)
library(shinyjs)
library(plotly)
ui <- dashboardPage(
dashboardHeader(title = "Biodiversity"),
dashboardSidebar(
actionButton("action","Submit")
),
dashboardBody(
useShinyjs(),
div(id='text_div',
verbatimTextOutput("text")
)
,
uiOutput("help_text"),
plotOutput("plot")
)
)
server <- function(input, output) {
output$help_text <- renderUI({
HTML("<b>Click 'Show plot' to show the plot.</b>")
})
observeEvent(input$action,{
hide("help_text")
output$plot <- renderPlot({
plot(1)
})
})}
shinyApp(ui = ui, server = server)
Output:

Sandwich icon position in shinydashboard

I would like to know if there's a way to put the the sandwich icon on the left side of the title name.
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(title = "Title"),
dashboardSidebar(
),
dashboardBody()
)
server <- function(input, output, session) {
}
shinyApp(ui = ui, server = server)
Perhaps you can just use an image in your www folder. Try this
ui <- dashboardPage(
dashboardHeader(
title = div(img(src = 'hotdog.png', title = "A Test Application", height = "30px"),
"My Title", style = "position: relative; margin:-3px 0px 0px 5px; display:right-align;"
)
),
dashboardSidebar(),
dashboardBody()
)
server <- function(input, output, session) {}
shinyApp(ui = ui, server = server)

Place text in the middle of shinydashboard body

How can you place text exactly in the middle between left and right end of shiny dashboard body at this height?
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(disable = T),
dashboardBody(
fluidRow(
column(5,),
column(4,
span(h2(strong("Covid-19 Situation Dashboard"), style = 'font-size:30px;color:#6cbabf;')))
)
)
)
server <- function(input, output) { }
shinyApp(ui, server)
Use align = "center", as shown below.
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(disable = T),
dashboardBody(
fluidRow(
#column(5,),
column(12,
span(h2(strong("Covid-19 Situation Dashboard"), align = "center", style = 'font-size:30px;color:#6cbabf;')))
)
)
)
server <- function(input, output) { }
shinyApp(ui, server)

Set font size and color in title of shinydashboard box

How can I change the font size and color of title in shinydashboard box()?
library(shiny)
library(plotly)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(width=12)),
fluidRow(
box(title="Title")
)
)
)
server <- function(input, output) {
}
shinyApp(ui, server)
r
You can use a header tag and style option within it.
library(shiny)
library(plotly)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(width=12)),
fluidRow(
box(title=h3("Title", style = 'font-size:42px;color:blue;'))
)
)
)
server <- function(input, output) {
}
shinyApp(ui, server)

gvisGeoChart with shiny Dashboard

Unable to get output for givsGeoChart in my shiny Dashboard.
Below is the code for the same.
library(shiny)
library(shinydashboard)
library(googleVis)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
htmlOutput("Accidents")
)
)
server <- function(input, output) {
output$Accidents <- renderGvis({
gvisGeoChart(Dum, "States","Road_Accident",
options=list(region="IN",displayMode="regions",resolution="provinces",width="100%"))
})
}
shinyApp(ui, server)
The above code doesn't work.
GeoStates_IN <- gvisGeoChart(Dum, "States","Road_Accident",options=list(region="IN",displayMode="regions",resolution="provinces",width="100%"))
plot(GeoStates_IN)
whereas this code works.Unable to figure out what is missing in above code.
Any kind of help is appreciated.
Problem has something to do with your options() or data. Is your variable dum cotaining columns "States" and "Road_Accident". Have you included the data in server.R?
This works:
library(shiny)
library(shinydashboard)
library(googleVis)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
htmlOutput("Accidents")
)
)
server <- function(input, output) {
output$Accidents <- renderGvis({
data(Exports)
#map<-gvisGeoChart(Exports, "States","Road_Accident",
#options=list(region="IN",displayMode="regions",resolution="provinces",width="100%"))
map<-gvisGeoChart(Exports, locationvar='Country', colorvar='Profit',
options=list(projection="kavrayskiy-vii"))
return(map)
})
}
shinyApp(ui, server)

Resources