Skip to content

Commit

Permalink
label widths in tar_visnetwork() and tar_mermaid(), descriptions in t…
Browse files Browse the repository at this point in the history
…ar_mermaid()
  • Loading branch information
wlandau committed Feb 19, 2024
1 parent 4c513bf commit 55ce991
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
8 changes: 7 additions & 1 deletion R/class_mermaid.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ mermaid_init <- function(
network,
label = NULL,
label_break = "<br>",
label_width = 60L,
show_legend = TRUE,
show_color = TRUE
) {
mermaid_new(
network = network,
label = label,
label_break = label_break,
label_width = label_width,
show_legend = show_legend,
show_color = show_color
)
Expand All @@ -18,13 +20,15 @@ mermaid_new <- function(
network = NULL,
label = NULL,
label_break = NULL,
label_width = NULL,
show_legend = NULL,
show_color = NULL
) {
mermaid_class$new(
network = network,
label = label,
label_break = label_break,
label_width = label_width,
show_legend = show_legend,
show_color = show_color
)
Expand All @@ -43,13 +47,15 @@ mermaid_class <- R6::R6Class(
network = NULL,
label = NULL,
label_break = NULL,
label_width = NULL,
show_legend = NULL,
show_color = NULL
) {
super$initialize(
network = network,
label = label,
label_break = label_break
label_break = label_break,
label_width = label_width
)
self$show_legend <- show_legend
self$show_color <- show_color
Expand Down
13 changes: 10 additions & 3 deletions R/tar_mermaid.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#' list(
#' tar_target(y1, 1 + 1),
#' tar_target(y2, 1 + 1),
#' tar_target(z, y1 + y2)
#' tar_target(z, y1 + y2, description = "sum of two other sums")
#' )
#' })
#' # Copy the text into a mermaid.js online editor
Expand All @@ -45,7 +45,8 @@ tar_mermaid <- function(
allow = NULL,
exclude = ".Random.seed",
outdated = TRUE,
label = NULL,
label = targets::tar_config_get("label"),
label_width = targets::tar_config_get("label_width"),
legend = TRUE,
color = TRUE,
reporter = targets::tar_config_get("reporter_outdated"),
Expand All @@ -60,7 +61,10 @@ tar_mermaid <- function(
force(envir)
tar_assert_lgl(targets_only, "targets_only must be logical.")
tar_assert_lgl(outdated, "outdated in tar_mermaid() must be logical.")
tar_assert_in(label, c("time", "size", "branches"))
tar_assert_in(label, c("description", "time", "size", "branches"))
tar_assert_dbl(label_width)
tar_assert_scalar(label_width)
tar_assert_none_na(label_width)
tar_assert_lgl(legend)
tar_assert_lgl(color)
tar_assert_scalar(legend)
Expand All @@ -81,6 +85,7 @@ tar_mermaid <- function(
exclude_quosure = rlang::enquo(exclude),
outdated = outdated,
label = label,
label_width = label_width,
legend = legend,
color = color,
reporter = reporter,
Expand Down Expand Up @@ -108,6 +113,7 @@ tar_mermaid_inner <- function(
exclude_quosure,
outdated,
label,
label_width,
legend,
color,
reporter,
Expand All @@ -130,6 +136,7 @@ tar_mermaid_inner <- function(
visual <- mermaid_init(
network = network,
label = label,
label_width = label_width,
show_legend = legend,
show_color = color
)
Expand Down
15 changes: 10 additions & 5 deletions man/tar_mermaid.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions man/tar_visnetwork.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 55ce991

Please sign in to comment.