【发布时间】:2019-03-07 18:17:52
【问题描述】:
我有一个使用 shinydashboard 制作的 R Shiny 应用程序,但在让 UI 填充浏览器窗口时遇到问题。
这是我的 ui.R 输出:
#
# This is the user-interface definition of a Shiny web application. You can
# run the application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here:
#
# http://shiny.rstudio.com/
#
## app.R ##
library(rsconnect)
library(shinydashboardPlus)
library(shinydashboard)
library(shiny)
#shinyApp(ui = ui, server = server, options = list(height = 1080))
ui <- dashboardPage(skin = "red",
dashboardHeader(title = "Miradashboard",
# This drop-down menu offers user and system administration within the application
dropdownMenu(type = "messages",
messageItem(
from = "Sales Dept",
message = "Sales are steady this month."
),
messageItem(
from = "New User",
message = "How do I register?",
icon = icon("question"),
time = "13:45"
),
messageItem(
from = "Support",
message = "The new server is ready.",
icon = icon("life-ring"),
time = "2014-12-01"
)
),
# This is a drop-down menu for checking notifications.
# This should alert users of alerts that have not been merged to a case in the last 15 days.
dropdownMenu(type = "notifications",
notificationItem(
text = "5 new users today",
icon("users")
),
notificationItem(
text = "12 items delivered",
icon("truck"),
status = "success"
),
notificationItem(
text = "Server load at 86%",
icon = icon("exclamation-triangle"),
status = "warning"
)
),
# This is a drop-down menu for checking tasks.
# This drop-down menu will eventually offer suggestions based off of ML Algorithms.
dropdownMenu(type = "tasks", badgeStatus = "success",
taskItem(value = 90, color = "green",
"Documentation"
),
taskItem(value = 17, color = "aqua",
"Project X"
),
taskItem(value = 75, color = "yellow",
"Server deployment"
),
taskItem(value = 80, color = "red",
"Overall project"
)
)
),
dashboardSidebar(
## Sidebar content
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Widgets", tabName = "widgets", icon = icon("th")),
menuItem("Reports", tabName = "reports", icon = icon("th")),
menuItem("OpsCare Clients", tabName = "OpsCare Clients", icon = icon("bar-chart-o")),
menuItem("ProdCare Clients", tabName = "ProdCare Clients", icon = icon("bar-chart-o")),
menuItem("Alerts", tabName = "Alerts", icon = icon("bar-chart-o")),
menuItem("Change Requests", tabName = "Change Requests", icon = icon("list-alt")),
menuItem("Maintenance Windows", tabName = "Maintenance Windows", icon = icon("list-alt")),
menuItem("Rundeck", tabName = "Rundeck", icon = icon("bars")),
menuItem("Salesforce", tabName = "Salesforce", icon = icon("bars")),
menuItem("Handovers", tabName = "Handovers", icon = icon("bars")),
menuItem("Jump-Host Access", tabName = "Jump-Host Access", icon = icon("bars"))
)
)
),
dashboardBody(
# Boxes need to be put in a row (or column)
fluidRow(
box(plotOutput("plot1", height = 250)),
box(plotOutput("plot2", height = 250)),
box(plotOutput("plot3", height = 250)),
#box(plotOutput("plot4", height = 250)),
#box(dataTableOutput("DT1", height = 250)),
box(
title = "Controls",
sliderInput("slider", "Number of observations:", 1, 100, 50)
)
)
)
)
server <- function(input, output) {
set.seed(122)
histdata <- rnorm(500)
# List Server Output whereby plot[1-#] is the plot box output in UI above.
# Server Output occurds and is defined by data variables
# histdata[seq_len(input$slider)] defines slider utilization
# hist(data) defines histogram off of "data"te
output$plot1 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
output$plot2 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
output$plot3 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
output$plot4 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
output$plot5 <- renderPlot({
data <- histdata[seq_len(input$slider)]
hist(data)
})
}
shinyApp(ui, server)
正如您在所附图片中看到的那样,该页面在 Web 浏览器中被切断。我的最终目标是将它扩展到全屏,因为我试图让内部用户可以使用和访问它。如果有人对如何将仪表板页面扩展到全尺寸有任何建议,那就太好了。
就尝试自己解决它而言,我已经研究了以下方面以将其扩展到全屏。
- 我查看了 shiny.js,但这似乎不是标准的存储库或通过 CRAN 安装
- 我查看了 fillPage 功能,但这使它成为 HTML 并且上面的代码不是 HTML 格式
- 我查看过调用“填充”页面功能,但在 Web 浏览器的完整页面视图中没有这样做。调用的命令放置在 ui 之后的 ad 之前
【问题讨论】:
-
我已经为你添加了图片,但你应该知道你可以通过点击标签列表下方的编辑按钮edit你的问题。为了便于阅读,应通过编辑问题的正文来进行更改或澄清,而不是在 cmets 中发布内容。
-
感谢@divibisan 我对在这个社区工作还很陌生,所以我仍在努力学习细节:D
-
别担心!我假设您尝试过查看 RStudio 浏览器之外的其他浏览器(通常会做一些奇怪的事情)?另外,您可以滚动截断的窗口以查看所有内容吗?
-
您是否尝试过在外部浏览器中运行它(而不是在 RStudio 查看器窗格中)?在我的系统上,整页显示正确。
标签: r shiny shinydashboard