图片作为闪亮的仪表板背景

时间:2019-02-07 07:38:06

标签: r shiny background shinydashboard

我想在闪亮的仪表板应用程序中更改背景。我使用了互联网功能setBackgroundImage(https://rdrr.io/cran/shinyWidgets/man/setBackgroundImage.html)。问题是我不知道是否应该将该功能放入我的应用程序中。例如经典应用程序,而不是仪表板。

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)

还可以将传单地图作为背景吗?

1 个答案:

答案 0 :(得分:1)

您可以使用function arrayCounter($data){ //At this point we have an array or an object. //Lets loop across the elements and see if we have any more nested arrays or objects. foreach($data as $key){ $count = 0; //Test each element to see if it's an object or an array. if(is_array($key) || is_object($key)){ //If it is we are going to send the element through another instance of the function. $count += arrayCounter($key); } //If the element is an array we are going to increment the counter. if(is_array($key)){ $count++; } } return $count; } $count = arrayCounter($data); echo 'Count: ' . $count; //Using your data this will return "2". 并将其位置属性指定为绝对值。请注意,必须将img标签放置在tags$img()中的第一位置:

dashboardBody

它也接受... dashboardBody( tags$img( src = "http://wallpics4k.com/wp-content/uploads/2014/07/470318.jpg", style = 'position: absolute' ), ... ) ... width参数。您还可以使用heighthspace参数定位图像。