Skip to content

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

Description

@NadiaAbraham

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()

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions