【发布时间】:2019-09-01 08:29:27
【问题描述】:
请执行以下代码并在主题选择器中选择深色,然后表格中的数字消失,因为数字的颜色在黑暗中是白色的,但背景也是白色的。
library(rhandsontable)
library(shiny)
editTable <- function(DF, outdir=getwd(), outfilename="table"){
ui <- shinyUI(fluidPage(
shiny::tags$head(
shinythemes::themeSelector(),
shiny::tags$style(shiny::HTML("
.ui-draggable {
z-index: 3;
background-color: #CCCCFF;
"))
),#taghead
titlePanel("Edit and save a table"),
sidebarLayout(
sidebarPanel(
helpText("Shiny app based on an example given in the rhandsontable package.",
"Right-click on the table to delete/insert rows.",
"Double-click on a cell to edit"),
wellPanel(
h3("Table options"),
radioButtons("useType", "Use Data Types", c("TRUE", "FALSE"))
),
br(),
wellPanel(
h3("Save"),
actionButton("save", "Save table")
)
),
mainPanel(
shiny::absolutePanel( draggable = T, style ="red",fixed=TRUE,
h3("Table options"),
rHandsontableOutput("hot"),
h3("Table options")
)
)
)
))
server <- shinyServer(function(input, output) {
values <- reactiveValues()
## Handsontable
observe({
if (!is.null(input$hot)) {
DF = hot_to_r(input$hot)
} else {
if (is.null(values[["DF"]]))
DF <- DF
else
DF <- values[["DF"]]
}
values[["DF"]] <- DF
})
output$hot <- renderRHandsontable({
DF <- values[["DF"]]
if (!is.null(DF))
rhandsontable(DF, useTypes = as.logical(input$useType), stretchH = "all")
})
## Save
observeEvent(input$save, {
finalDF <- isolate(values[["DF"]])
saveRDS(finalDF, file=file.path(outdir, sprintf("%s.rds", outfilename)))
})
})
## run app
runApp(list(ui=ui, server=server))
return(invisible())
}
editTable(DF=data.frame(a=c(1,2),b=c(3,4)))
下图显示了当主题较暗时单元格中的数字消失。
有什么方法可以避免这种消失吗? 我不知道如何通过 css 避免。
【问题讨论】: