【发布时间】:2020-03-03 21:13:17
【问题描述】:
我在一个闪亮的应用程序中有一个 rhandsontable。 我的目标是根据列的总和为列中的所有单元格着色。 例如:如果列中的值之和为 1,则该列中的所有单元格都被着色为绿色。
显示给用户的预期结果是这样的:
似乎可以使用这样的 JS 格式来做到这一点:
rhandsontable(myrhandsontable) %>%
hot_cols(renderer ="some JS script")
我以前从未做过任何 JS,我很难得到“some JS script”部分中列的总和。
这是一个可复制的最小示例:
library(shiny)
library(rhandsontable)
library(tidyverse)
# basic user interface (not important here)
ui <- fluidPage(
rHandsontableOutput(outputId = "ex")
)
# server side calculations
server <- function(input, output) {
# create a dummy dataset
ex_data = data.frame(id = letters[1:3],
attr1 = c(0.5, 0.4, 0.3),
attr2 = c(0.6, 0.3, 0.1))
# create the rhandsontable object and define conditional formatting
output$ex = renderRHandsontable({
rhandsontable(ex_data) # %>% renderer ="JS script for conditional formatting")
})
我尝试使用这些帖子和教程失败了:
- rhandsontable change background of specific row
- Rhandsontable conditional formatting- How to highlight rows based on specific attribute value?
- https://jrowen.github.io/rhandsontable/#custom_renderer_using_r
- https://jrowen.github.io/rhandsontable/#conditional_formatting
欢迎任何想法:)
【问题讨论】:
标签: javascript r shiny rhandsontable