【发布时间】:2021-05-06 22:18:10
【问题描述】:
我在 Shiny 应用程序的 DT::datatable 列中显示带有迷你图的图标时遇到了一些问题,即使我已经转义了 HTML。
编辑:删除第二个问题。
library(shiny)
library(dplyr)
ui <- fluidPage(
htmlwidgets::getDependency('sparkline'),
DT::dataTableOutput("table")
)
server <- function(input, output) {
raw_data <- data.frame(date = 2000:2021,
value = sample(100:500, 22),
icon = as.character(icon("arrow-up")))
data <- raw_data %>%
group_by(icon) %>%
# Create the sparkline
summarise("value" = sparkline::spk_chr(c(value),
xvalues = date,
tooltipFormat = '{{x}}: {{y}}'))
output$table <- DT::renderDataTable({
cb <- htmlwidgets::JS('function(){debugger;HTMLWidgets.staticRender();}')
DT::datatable(data = data,
escape = FALSE,
options = list(drawCallback = cb))
})
}
shinyApp(ui, server)
【问题讨论】:
-
欢迎来到 SO。请不要在同一个帖子中问两个问题。规则是每个帖子一个问题。
标签: r shiny datatables dt sparklines