【发布时间】:2021-05-05 18:31:32
【问题描述】:
我在 Wellpanel 中放置了 3 个按钮图标。
问题是所有 3 个图标都没有出现在一行中(“屏幕截图”图标出现在第一行,而接下来的 2 个图标出现在第二行)。
我尝试与“fixedRow”和“style”对齐,但无法实现。
谁能帮我做这件事?
谢谢...
脚本:
TableA = data.frame(Product = c('iPhone', 'Macbook', 'Airpod', 'Macbook', 'Airpod', 'Macbook', 'iPhone'), East = c(1:7), West = c(5:11), North = c(15:21), South = c(24:30))
library(shiny)
library(shinythemes)
library(DT)
library(rhandsontable)
library(tidyverse)
library(tidyquant)
library(knitr)
library(gt)
library(shinycssloaders)
library(shinydashboard)
library(shinyWidgets)
header = dashboardHeader(title = 'Shiny Dashboard', titleWidth = 400)
sidebar = dashboardSidebar(
wellPanel(
"Export Options", id = "DownloadPanel", style = "background: #222d32; max-height: 145px; max-width: 220px; align-items: center",
fixedRow(tags$div(style="display: inline-block; vertical-align:center; horizontal-align:center", class = "row-fluid",
screenshotButton(selector="#TableC", label = NULL, filename = paste("Summary")),
downloadButton(outputId = "SummaryExcelDownload", label = NULL, icon = icon("file-excel"), class = "butt1",
tags$head(tags$style(".butt{background-color:white;} .butt1{color: #217346 !important;}"))),
downloadButton(outputId = "SummaryPdfDownload", label = NULL, icon = icon("file-pdf"), class = "butt2",
tags$head(tags$style(".butt{background-color:white;} .butt2{color: #b30c00 !important;}")))
))
)
)
body <- dashboardBody(uiOutput("mainpanel"))
ui = dashboardPage(header, sidebar, body)
############
server = function(input, output, session)
{
output$mainpanel = renderUI({
fluidRow(tabBox(width = 250, height = 100,
tabPanel("Apple Sales", value = 'tab1', gt_output(outputId = "TableC")%>% withSpinner(color="#3483CA", type = 1, size = 2))
))
})
TableB = as.data.frame(TableA) %>%
gt() %>%
grand_summary_rows(columns = 2:5, fns = list(TotalSales = "sum")) %>%
tab_options(grand_summary_row.background.color = "#DDEBF7") %>%
cols_width(columns = 1 ~ px(1), columns = 2 ~ px(300), everything() ~ px(100)) %>%
tab_spanner(label = "Sales", columns = 3:6)
output$TableC = render_gt(expr = TableB)
output$SummaryExcelDownload = downloadHandler(
filename = "Summary.pdf",
content = function(file) {write.xlsx(TableC, file)})
output$SummaryPdfDownload = downloadHandler(
filename = "Summary.pdf",
content = function(file) {write.xlsx(TableC, file)})
}
############
shinyApp(ui = ui, server = server)
输出:
注意: 请忽略 excel 和 pdf 下载的“服务器”参数(输出 $SummaryExcelDownload 和输出 $SummaryPdfDownload),因为我仍在探索纠正相同的问题。
【问题讨论】:
-
包裹在
div()中应该连续显示,只要宽度足够。
标签: r shiny shinydashboard shinyapps