insightsengineering / insightsengineering/teal.widgets

[Bug]: Unable to render gridified rtables with teal.widgets::table_with_settings_srv

Open
#334 4 comments 0 reactions 0 assignees View on GitHub
bug core
Dominant language
R
Stars
6
Forks
8
PR merge metrics
No merged PRs in 30d

Description

### What happened?

I am trying to use gridify to add watermark to rtables rendered with teal.widgets::table_with_settings_srv similar to the approach used in teal.modules.clinical package. However, it's not working. Appreciate any help on this. Thanks in advance.
Sample app:

```
library(shiny)
library(gridify)
library(teal.widgets)
app1 <- shinyApp(
ui = fluidPage(
table_with_settings_ui(
id = "table_with_settings1"
),
table_with_settings_ui(
id = "table_with_settings2"
)
),
server = function(input, output, session) {
table_r1 <- reactive({
l <- basic_table() %>%
split_cols_by("Species") %>%
analyze(c("Sepal.Length", "Sepal.Width"))
tbl <- build_table(l, iris)
tbl
})
table_with_settings_srv(id = "table_with_settings1",
table_r = table_r1)
table_r2 <- reactive({
gridify_layout <- gridify::gridifyLayout(
nrow = 3L,
ncol = 1L,
heights = grid::unit(c(0.05, 0.9, 0.05), "npc"),
widths = grid::unit(1, "npc"),
margin = grid::unit(c(t = 0.1, r = 0.1, b = 0.1, l = 0.1), units = "cm"),
global_gpar = grid::gpar(),
background = grid::get.gpar()$fill,
adjust_height = FALSE,
object = gridifyObject(row = 2, col = 1),
cells = gridifyCells(
title = gridifyCell(row = 1, col = 1),
footer = gridifyCell(row = 3, col = 1),
watermark = gridifyCell(row = 1:3, col = 1, rot = 45, gpar = grid::gpar(fontsize = 90, alpha = 0.3))
)
)
l <- basic_table() %>%
split_cols_by("Species") %>%
analyze(c("Sepal.Length", "Sepal.Width"))
tbl <- build_table(l, iris)
tbl_gridified <- gridify::gridify(
object = rtables.officer::tt_to_flextable(tbl, theme = NULL),
layout = gridify_layout
) %>%
set_cell("watermark", "DRAFT")
tbl_gridified
})
table_with_settings_srv(id = "table_with_settings2",
table_r = table_r2)

}
)

if (interactive()) {
runApp(app1)
}
```

### sessionInfo()

```R

```

### Relevant log output

```R

```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct.

### Contribution Guidelines

- [x] I agree to follow this project's Contribution Guidelines.

### Security Policy

- [x] I agree to follow this project's Security Policy.

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied Shiny app and comparing the two table_with_settings_srv calls, especially the gridify conversion through rtables.officer::tt_to_flextable. Trace why the gridified table does not render its watermark in the widget; done means the second table displays the expected DRAFT watermark.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.