開始使用免費開始

用 box 進行線框規劃(wireframing)

新的列由 fluidRow() 定義。

此外,可以在 body 中加入 box() 來組織內容。可以加入多個 box(),每個預設寬度為 6,並可用 width 引數調整。由於每列的最大寬度是 12,因此同一列中最多只能放兩個預設的 box()。你也可以設定 height,以加入不同尺寸的 box。

這些 box() 在此有兩個主要用途。第一,幫你整理 shinydashboard 的各個元素;第二,做線框規劃(wireframing),讓你在加入內容前先規劃各物件的擺放位置。

在這個練習中,你會用空的 box 來進行線框規劃。

shinyshinydashboard 套件已載入。儀表板的標頭與側邊欄分別存為 headersidebar

本練習屬於課程

使用 shinydashboard 建立儀表板

檢視課程

練習說明

  • 在第一列加入三個 box(),寬度分別為 2、2、8。
  • 在第二列加入一個 box(),填滿整列,且高度為 200。
  • 在第三列加入兩個等寬的空 box,分別標示為「A slider goes here」與「Some info boxes go here」。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

body <- dashboardBody(
  # Add three boxes with widths 2, 2 and 8
  fluidRow(box("Some buttons go here", ___, height = 100), 
           ___("Checkboxes go here", ___, height = 50),
           ___("A chart goes here", ___, height = 150)),
  # Add one box that fills the entire row and has height 200
  fluidRow(___("Data table goes here"), ___, ___),
  # Add a third row containing two boxes with equal widths
  fluidRow(___)
)

ui <- dashboardPage(header, sidebar, body)
server <- function(input, output){}
shinyApp(ui, server)
編輯並執行程式碼