我正在尝试使用R Shiny格式化表格,并且横条显示的很好,它们之间的行之间没有任何空格(或轮廓)。我的代码如下:
formatStyle('score', background = styleColorBar(real$score,
'lightblue'),
backgroundSize = '100% 50%',
backgoundRepeat = 'no-repeat',
backgroundPosition = 'center')
我正在寻找的东西是这样的:
答案 0 :(得分:2)
这是一个可能的解决方案:
---
title: "Untitled"
author: "Author X. Person"
date: "October 11, 2018"
output: html_document
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r tabsets, echo=FALSE, message=FALSE, warning=FALSE}
library(DT)
library(data.table)
d = data.table(x = 1:10,time = as.POSIXct('2018-10-11 12:00:00.123'))
d$score <- seq(1,10,1)
datatable(d, options=list(
initComplete = JS("
function(settings, json) {
$(this.api().table().td()).css({
'border-collapse': 'collapse',
'border-bottom-width': '4px',
'background-color': '#000',
'color': '#eee'
});
}"),
pageLength = 10,
lengthMenu = c(2, 12, 18),
searching= FALSE)) %>%
formatStyle('score', background = styleColorBar(d$score, 'lightblue'),
backgroundSize = '100% 50%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'center')
```
结果如下: