Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

picture as a background of shiny dashboard

I would like to change background in my shiny dashboard App. I wound in internet function setBackgroundImage (https://rdrr.io/cran/shinyWidgets/man/setBackgroundImage.html). The problem is that I don't know were I should put that function in my app. In example is classic app, not dashboard.

library(shiny)
library(shinydashboard)
library(shinyWidgets)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    setBackgroundImage(src = "http://wallpics4k.com/wp-content/uploads/2014/07/470318.jpg")
  )
)
server <- function(input, output) {}
shinyApp(ui, server)

Also it is possible to put leaflet map as a background?

like image 908
dasti74 Avatar asked Feb 07 '19 07:02

dasti74


People also ask

What is bs4Dash?

bs4Dash: A 'Bootstrap 4' Version of 'shinydashboard'Make 'Bootstrap 4' Shiny dashboards. Use the full power of 'AdminLTE3', a dashboard template built on top of 'Bootstrap 4' <https://github.com/ColorlibHQ/AdminLTE>.

What is Dashboard in R shiny?

Shiny dashboards let you access a complete web application framework within the R environment. Easily turn your work in R, analyses and visualizations, machine learning models, and more into web applications that deliver value to businesses.


Video Answer


2 Answers

You can do it with tags$img(), and specifying position attribute to absolute. Note that img tag have to be placed as first in dashboardBody:

...
  dashboardBody(
    tags$img(
      src = "http://wallpics4k.com/wp-content/uploads/2014/07/470318.jpg",
      style = 'position: absolute'
    ),
    ...
  )
...

It also accepts width and height parameters. You can also position your image with hspace and vspace parameters.

like image 187
Paweł Chabros Avatar answered Oct 16 '22 23:10

Paweł Chabros


Now there is also the possibility to add shinydashboard = TRUE to the setBackgroundImage function.

library(shiny)
library(shinydashboard)
library(shinyWidgets)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    setBackgroundImage(
      src = "https://www.fillmurray.com/1920/1080",
      shinydashboard = TRUE
    )
  )
  
)
server <- function(input, output) {}
shinyApp(ui, server)
like image 23
Pedrinho Avatar answered Oct 16 '22 22:10

Pedrinho