R shiny dataable with styleColorBar 不对齐左侧的数据
R shiny datable with styleColorBar not aligning the data on the left hand side
我有以下代码,我的目标是将 styleColorBar 添加到 WGT 列,对齐列左侧的黄色条。
df = data.frame(WGT=c(10, 10, 15, 5, 30, 8, 2, 5, 1, 4, 10),
STATE=c("NY","NJ","OH","TX","CA","NC","MA","FL","AL","PA","AZ"), stringsAsFactors = F)
dft <- datatable(df, rownames= T,
options = list(scrollX = T
, lengthChange = F
, paging =F # this completely hides the Next, Previous and Page number at the bottom of the table
, autoWidth = F
, pageLength = 20 # this determines how many rows we want to see per page
, info = F # this will hide the "Showing 1 of 2..." at the bottom of the table -->
, searching = F # this removes the search box ->
))
dft <- dft %>% formatStyle('WGT',
background = styleColorBar(df[,'WGT'], 'yellow'),
backgroundSize = '100% 80%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'left')
如您所见,水平黄色条在 WGT 列的右侧对齐,我不明白为什么。我在这里查看了其他类似的帖子,但找不到这个可能很简单的问题的答案。
谢谢
styleColorBar函数中的角度参数怎么样?
试试这个:
dft <- dft %>% formatStyle('WGT',
background = styleColorBar(df[,'WGT'], 'yellow', angle = -90),
backgroundSize = '100% 80%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'center')
输出:
我有以下代码,我的目标是将 styleColorBar 添加到 WGT 列,对齐列左侧的黄色条。
df = data.frame(WGT=c(10, 10, 15, 5, 30, 8, 2, 5, 1, 4, 10),
STATE=c("NY","NJ","OH","TX","CA","NC","MA","FL","AL","PA","AZ"), stringsAsFactors = F)
dft <- datatable(df, rownames= T,
options = list(scrollX = T
, lengthChange = F
, paging =F # this completely hides the Next, Previous and Page number at the bottom of the table
, autoWidth = F
, pageLength = 20 # this determines how many rows we want to see per page
, info = F # this will hide the "Showing 1 of 2..." at the bottom of the table -->
, searching = F # this removes the search box ->
))
dft <- dft %>% formatStyle('WGT',
background = styleColorBar(df[,'WGT'], 'yellow'),
backgroundSize = '100% 80%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'left')
如您所见,水平黄色条在 WGT 列的右侧对齐,我不明白为什么。我在这里查看了其他类似的帖子,但找不到这个可能很简单的问题的答案。 谢谢
styleColorBar函数中的角度参数怎么样?
试试这个:
dft <- dft %>% formatStyle('WGT',
background = styleColorBar(df[,'WGT'], 'yellow', angle = -90),
backgroundSize = '100% 80%',
backgroundRepeat = 'no-repeat',
backgroundPosition = 'center')
输出: