如何在闪亮的 rhandsontable 中使列标题字母加粗
How to make column heading letters bold in rhandsontable in shiny
如何在闪亮的 r 包中的 rhandsontable 中将列标题加粗?
我有一个闪亮的 rhandsontable,我想将 header 中的文本加粗。我该怎么做?有人知道吗?
rhandsontable 是 Handsontable.js 库的接口,因此可以使用 CSS 对其进行自定义。取如下数据框:
DF = data.frame(column.one = 1:10,
column.two = TRUE)
rhandsontable(DF)
看起来this没有任何定制。
但是如果你指定使用CSS,你可以引用它:
DF = data.frame(column.one = 1:10,
column.two = TRUE)
func = "function (col) { # custom CSS
switch (col) {
case 0:
return '<b>Bold</b> and <em>Italics</em>';
case 1:
return '<em>Bold</em> and <b>Italics</b>';
}
}"
rhandsontable(DF, colHeaders = htmlwidgets::JS(func))
你最终得到 this。
确保在调用 rhandsontable 函数时指定 colHeaders 参数。
您可以将一些 style
添加到您的 table 中:
library(shiny)
library(rhandsontable)
ui <- fluidPage(
rHandsontableOutput("table1"),
tags$style(type="text/css", "#table1 th {font-weight:bold;}")
)
server=function(input, output, session) {
output$table1 <- renderRHandsontable({
rhandsontable(mtcars,rowHeaders=F)
})
}
shinyApp(ui,server)
如何在闪亮的 r 包中的 rhandsontable 中将列标题加粗?
我有一个闪亮的 rhandsontable,我想将 header 中的文本加粗。我该怎么做?有人知道吗?
rhandsontable 是 Handsontable.js 库的接口,因此可以使用 CSS 对其进行自定义。取如下数据框:
DF = data.frame(column.one = 1:10,
column.two = TRUE)
rhandsontable(DF)
看起来this没有任何定制。
但是如果你指定使用CSS,你可以引用它:
DF = data.frame(column.one = 1:10,
column.two = TRUE)
func = "function (col) { # custom CSS
switch (col) {
case 0:
return '<b>Bold</b> and <em>Italics</em>';
case 1:
return '<em>Bold</em> and <b>Italics</b>';
}
}"
rhandsontable(DF, colHeaders = htmlwidgets::JS(func))
你最终得到 this。
确保在调用 rhandsontable 函数时指定 colHeaders 参数。
您可以将一些 style
添加到您的 table 中:
library(shiny)
library(rhandsontable)
ui <- fluidPage(
rHandsontableOutput("table1"),
tags$style(type="text/css", "#table1 th {font-weight:bold;}")
)
server=function(input, output, session) {
output$table1 <- renderRHandsontable({
rhandsontable(mtcars,rowHeaders=F)
})
}
shinyApp(ui,server)