R闪亮的ConditionalPanel不使用CSS样式表
我正在使用Rshinny构建一个web应用程序 我使用conditionPanels(有时)根据对象的类型显示透视表R闪亮的ConditionalPanel不使用CSS样式表,css,r,shiny,rpivottable,Css,R,Shiny,Rpivottable,我正在使用Rshinny构建一个web应用程序 我使用conditionPanels(有时)根据对象的类型显示透视表df 如下所示,如果透视表显示在conditionalpanel中,css将被忽略,透视表将以默认样式显示。但是,如果我包含第二个数据透视表,而不是在conditionalpanel中呈现,则两个数据透视表的样式都与custom.css中描述的样式相同 当没有第二个数据透视表时,如何确保第一个数据透视表使用样式表 # Server.R server <- shinyServe
df
如下所示,如果透视表显示在conditionalpanel中,css将被忽略,透视表将以默认样式显示。但是,如果我包含第二个数据透视表,而不是在conditionalpanel中呈现,则两个数据透视表的样式都与custom.css中描述的样式相同
当没有第二个数据透视表时,如何确保第一个数据透视表使用样式表
# Server.R
server <- shinyServer(function(input, output,session){
df <- data.frame(col1 = c('a','b','c'),
col2 = c(1,2,3))
## Output PivotTable
output$pivotTable <- rpivotTable::renderRpivotTable({
rpivotTable(data = df,
aggregatorName = 'Sum',
rendererName = 'Table')
})
## Output PivotTable2
output$pivotTable2 <- rpivotTable::renderRpivotTable({
rpivotTable(data = df,
aggregatorName = 'Sum',
rendererName = 'Table')
})
condition <- ifelse(is.data.frame(df), 'true', 'false')
## Output PivotTable
output$panelTable <- renderUI({
conditionalPanel(
condition,
rpivotTableOutput("pivotTable")
)
})
})
# UI.R:
ui <- dashboardPage(
title = "",
## Header content + dropdownMenu
dashboardHeader(
title = tags$b(""),
titleWidth = 250
),
## Sidebar content
dashboardSidebar(
width = 250,
sidebarMenu(
id = "tabs",
menuItem("tab1", tabName = "tab", icon = icon("table"))
)
),
## Body content
dashboardBody(
tags$head(tags$link(rel = "stylesheet", type = "text/css", href = "custom.css")),
tabItems(
tabItem(tabName = "tab",
div(
uiOutput('panelTable')
),
div(
rpivotTableOutput("pivotTable2")
)
)
)
)
)
# Create Shiny object
shinyApp(ui = ui, server = server)
我认为您可以尝试在div中定义类 例如:
div(class = "pvtRows pvtAxisContainer",
uiOutput('panelTable')
)
您好,您的问题是,您的css被数据透视表生成的css规则推翻,从而覆盖了此添加
!重要信息
在每个规则之后,如下所示
#pivotTable{
overflow-x: scroll;
overflow-y: scroll;
}
.pvtRows, .pvtCols {
background: #FAFAFA none repeat scroll 0 0 !important;
}
table.pvtTable tbody tr th, table.pvtTable thead tr th {
background: #FFFFFF!important;
}
.pvtAxisContainer li span.pvtAttr {
background: rgba(147,255,53,0.8) !important;
}
希望这有帮助 嗨,这些答案对你有帮助吗?还是问题仍未解决?
#pivotTable{
overflow-x: scroll;
overflow-y: scroll;
}
.pvtRows, .pvtCols {
background: #FAFAFA none repeat scroll 0 0 !important;
}
table.pvtTable tbody tr th, table.pvtTable thead tr th {
background: #FFFFFF!important;
}
.pvtAxisContainer li span.pvtAttr {
background: rgba(147,255,53,0.8) !important;
}