Skip to content

Commit 7290384

Browse files
authored
ID:362481 [dv.papo] long labels in plot overlap (#49)
* Wrap decode column into no more than two lines * Update DESCRIPTION and NEWS.md
1 parent bf32f12 commit 7290384

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: dv.papo
22
Title: Patient Profile
3-
Version: 2.2.0-9000
3+
Version: 2.2.0-9001
44
Authors@R:
55
c(person("Boehringer-Ingelheim Pharma GmbH & Co.KG", role = c("cph", "fnd")),
66
person(given = "Korbinian",

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
# dv.papo 2.2.0-9001
2+
3+
- Wrap decode column into no more than two lines (to avoid overlap).
4+
15
# dv.papo 2.2.0-9000
6+
27
- [NOT USER-FACING] Tweak lintr rules.
38

49
# dv.papo 2.2.0

R/mod_plots.R

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,17 @@ patient_plot_server <- function(id, subject_var,
302302
}
303303
}
304304

305-
# wrap decode column
306-
df[["decode"]] <- strwrap(df[["decode"]],
307-
width = CONST$decode_max_width_before_wrap_in_characters,
308-
simplify = FALSE
309-
) |> sapply(function(x) paste(x, collapse = "\n"))
305+
# Wrap decode column into no more than two lines (to avoid overlap). Increment width one-by-one,
306+
# from the larger of the preset constant or an estimate (mid-point of longest decode text), until
307+
# all decode texts fit over a maximum of two lines.
308+
width_estimate <- ceiling(nchar(as.character(df[["decode"]])) / 2)
309+
max_width <- max(width_estimate, CONST$decode_max_width_before_wrap_in_characters)
310+
repeat {
311+
wrapped <- strwrap(df[["decode"]], width = max_width, simplify = FALSE)
312+
if (max(lengths(wrapped)) <= 2) break
313+
max_width <- max_width + 1
314+
}
315+
df[["decode"]] <- sapply(wrapped, function(x) paste(x, collapse = "\n"))
310316

311317
df <- df[intersect(names(df), c("start_date", "end_date", "decode", "grading", "serious_ae"))]
312318

0 commit comments

Comments
 (0)