Skip to content

📑 Refactor: Adds new teal_report, teal_card class and revamps reporter UI#331

Merged
averissimo merged 322 commits into
mainfrom
teal_reportable
Sep 4, 2025
Merged

📑 Refactor: Adds new teal_report, teal_card class and revamps reporter UI#331
averissimo merged 322 commits into
mainfrom
teal_reportable

Conversation

@averissimo

@averissimo averissimo commented Jun 3, 2025

Copy link
Copy Markdown
Contributor

github-actions Bot and others added 30 commits April 1, 2025 23:13
Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>

@m7pr m7pr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is 5 last tests failing + then a review of R CMD CHECK.
We should also merge those 2 PRs

Lastly we postponed one TODO into a specific issue

and also we will continue, but on another PR, with vignettes

where we outlined that we will also rethink after function naming and implementaion

averissimo and others added 7 commits September 3, 2025 14:08
…383)

# Pull Request

- Fixes insightsengineering/coredev-tasks#390

### Changes description

- Adds global option that sets the default size for plots
- Allows to customise dimensions on `chunk_output` attributes
(`dev.width` and `dev.height`)

<details>

<summary>Example app (KM + custom sized Histogram in reports)</summary>

```r
# Make sure the required branches are checked-out
# - teal_reporter (all 4: teal, teal.reporter, teal.code, teal.data)
# - redesign@main (teal, teal.reporter, teal.code)
pkgload::load_all("../teal.reporter")
pkgload::load_all("../teal")

example_extended <- function(label = "example teal module",
                             datanames = "all",
                             transformators = list(),
                             decorators = list()) {
  checkmate::assert_string(label)
  checkmate::assert_list(decorators, "teal_transform_module")

  mod <- example_module(label, datanames, transformators, decorators)

  module(
    label,
    server = function(id, data, decorators) {
      moduleServer(id, function(input, output, session) {
        result <- mod$server("example", data, decorators)

        reactive({
          q <- result()
          teal_card(q) <- c(teal_card(q), "### Iris")
          q <- q |>
            within(
              hist(1:10)
            )
          attr(teal_card(q)[[length(teal_card(q))]], "dev.width") <- 200
          attr(teal_card(q)[[length(teal_card(q))]], "dev.height") <- 200
          q <- q |>
            within({
              something <- iris
              something
            })
          q
        })

      })
    },
    ui = function(id, decorators) mod$ui(shiny::NS(id, "example"), decorators),
    ui_args = mod$ui_args,
    server_args = mod$server_args,
    datanames = mod$datanames,
    transformators = mod$transformators
  )
}

data <- teal_data()
data <- within(data, {
  library(dplyr)
  ADSL <- teal.modules.clinical::tmc_ex_adsl
  ADTTE <- teal.modules.clinical::tmc_ex_adtte
  iris <- iris
  CO2 <- CO2
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
#'
ADSL <- data[["ADSL"]]
ADTTE <- data[["ADTTE"]]
#'
arm_ref_comp <- list(
  ACTARMCD = list(
    ref = "ARM B",
    comp = c("ARM A", "ARM C")
  ),
  ARM = list(
    ref = "B: Placebo",
    comp = c("A: Drug X", "C: Combination")
  )
)


teal::init(
  data = data,
  modules = modules(
    tm_g_km(
      label = "Kaplan-Meier Plot",
      dataname = "ADTTE",
      arm_var = choices_selected(
        variable_choices(ADSL, c("ARM", "ARMCD", "ACTARMCD")),
        "ARM"
      ),
      paramcd = choices_selected(
        value_choices(ADTTE, "PARAMCD", "PARAM"),
        "OS"
      ),
      arm_ref_comp = arm_ref_comp,
      strata_var = choices_selected(
        variable_choices(ADSL, c("SEX", "BMRKR2")),
        "SEX"
      ),
      facet_var = choices_selected(
        variable_choices(ADSL, c("SEX", "BMRKR2")),
        NULL
      )
    ),
    example_extended(label = "🆕 Module (extended)")
  )
) |> shiny::runApp()
```

</details>

---------

Signed-off-by: André Veríssimo <211358+averissimo@users.noreply.github.com>
Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Co-authored-by: Marcin <133694481+m7pr@users.noreply.github.com>
Comment thread tests/testthat/test-teal_card.R
m7pr and others added 4 commits September 3, 2025 16:04
…d for the first time (#390)

Fixes #387

---------

Signed-off-by: Marcin <133694481+m7pr@users.noreply.github.com>
Co-authored-by: André Veríssimo <211358+averissimo@users.noreply.github.com>

@m7pr m7pr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done. Last thing would be #314 and #315 tackled in the next PR

@averissimo averissimo enabled auto-merge (squash) September 4, 2025 12:28
@averissimo averissimo merged commit 2c5cfcf into main Sep 4, 2025
28 of 29 checks passed
@averissimo averissimo deleted the teal_reportable branch September 4, 2025 12:52
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants