我已经创建了一个可React的“MasterIndexTable”,其中表中的最后一列“Rank”是1到435的值。我已经定义了一个调色板,所以单元格1得到红色,435得到蓝色。但是,由于该调色板的背景颜色是暗的,因此我想将这些单元格值的字体更改为白色。
我不知道如何编辑单个列的字体颜色?我假设它发生在[Rank - colDef]组件中?
RtoDColorPalette <- function(x) rgb(colorRamp(c("red","blue"))(x),maxColorValue = 255)
MasterIndexTable <- reactable(
HousePVI,
columns = list(
ID_No = colDef(show = FALSE),
State = colDef(defaultSortOrder = "asc", width = 60),
District_Number = colDef(name = "District", defaultSortOrder = "asc", width = 70),
First_Name = colDef(name = "First Name"),
Last_Name = colDef(name = "Last Name"),
Member_Party = colDef(name = "Party", width = 60),
PVI_Lean = colDef(name = "PVI Lean", width = 60),
PVI_Value = colDef(name = "PVI Value", width = 60),
Rank = colDef(name = "Rank (Most Republican (1) to Most Democratic (435)", width = 230,
style = function(value) {
normalized <- (value - min(HousePVI$Rank))/(max(HousePVI$Rank) min(HousePVI$Rank))
color <- RtoDColorPalette(normalized)
list(background = color)
}
)
),
theme = reactableTheme(
color = 'black',
backgroundColor = 'white',
borderColor = 'black',
stripedColor = 'aliceblue' )
)
字符串
1条答案
按热度按时间smtd7mpg1#
在样式函数中,将
color="white"
添加到返回的list
中。使用虚假数据:
字符串
的数据