如何在闪亮的应用程序中更改DT表的颜色主题?默认情况下,它对交替的行使用深色和浅灰色。我正在使用Sales_pivot = pd.pivot_table(Sales_Info, index=["Sub- Hub"], values="Net Sales In Pricing Currency (USD)",aggfunc=sum)
Sales_pivot.head()
。但是它不起作用,因为它仅适用于列
formatStyle(target = 'row', backgroundColor = c('yellow', 'red')
答案 0 :(得分:2)
这应该做,请注意我将标题颜色保留为白色:
library(shinydashboard)
library(shiny)
library(DT)
header <- dashboardHeader(title = 'title')
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem('dashboard', tabName = 'dashboard', icon = icon('dashboard'))
)
)
body <- dashboardBody(
tags$style(HTML('table.dataTable tr:nth-child(even) {background-color: pink !important;}')),
tags$style(HTML('table.dataTable tr:nth-child(odd) {background-color: yellow !important;}')),
tags$style(HTML('table.dataTable th {background-color: white !important;}')),
box(
title = 'box', width = NULL, status = 'primary',
DT::dataTableOutput('table2')
)
)
ui<-dashboardPage(header, sidebar, body)
server = function(input, output) {
output$table2 = DT::renderDataTable(
iris, options = list(lengthChange = FALSE)
)
}
shinyApp(ui, server)