開始使用免費開始

結合 UI/UX 原則進行 Wireframe 設計

現在來為你的儀表板做 wireframe,同時套用一些設計原則。請注意,本練習不會繪出任何視覺化圖表。

想像你要為 Sally 建立一個儀表板,她的投資組合包含 2 檔股票:Apple(AAPL)與 Disney(DIS)。在她的儀表板上,你會放入哪些內容?

可考量的變數包含每檔股票每日開盤與收盤價,分別以 openclose 表示,以及當日最高與最低價,分別以 highlow 表示。另一個重要變數是當日交易量(也就是當日成交股數),以 volume 表示。

本練習已為你載入 shinydashboardshiny 函式庫,並提供一個空的 server() 函式。

本練習屬於課程

使用 shinydashboard 建立儀表板

檢視課程

動手互動練習

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

library(shinydashboard)
library(shiny)

header <- dashboardHeader(
  title = "Portfolio dashboard for Sally",
  titleWidth = 300
)

sidebar <- dashboardSidebar(
  width = 300,
  sidebarMenu(
    id = "pages",
    menuItem("Historical trends",
             tabName = "historical"),
    menuItem("Profits and Losses (PnLs)", 
             tabName = "profit", 
             icon = icon("money-bill-alt"),
             # Truncate the number in the badge label to 2 decimal places
             badgeLabel = "+2.324815454862%", 
             # Change the badge color to green
             badgeColor = "red")
  )
)

body <- dashboardBody(tabItems(
  tabItem(tabName = "historical",
          fluidRow(box(selectInput("stock", "Select stock symbol", 
                                   choices=c("AAPL", "DIS"))),
                   box("Stock name", width = 6)),
          fluidRow(box("valueBox", "Open", width = 2), 
                   box("valueBox", "High", width = 2),
                   box("valueBox", "Low", width = 2),
                   box("valueBox", "Close", width = 2),
                   box("valueBox", "Volume", width = 2)),
          fluidRow(box("valueBox", "Open % change", width = 2, color = "red"), 
                   box("valueBox", "High % change", width = 2),
                   box("valueBox", "Low % change", width = 2),
                   box("valueBox", "Close % change", width = 2),
                   box("valueBox", "Volume % change", width = 2))),
  tabItem(tabName = "profit",
          fluidRow(box("valueBox", "Account balance", width = 3),
                   box("valueBox",  "Value at Risk (Var)", width = 3),
                   box("valueBox", "Returns", width = 3),
                   box("valueBox", "Profit-to-loss ratio", width = 3)),
          fluidRow(box("PnL chart", width = 12, height = 400)))
)
)

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