diff --git a/R/class_mermaid.R b/R/class_mermaid.R index 636ade79..cf864481 100644 --- a/R/class_mermaid.R +++ b/R/class_mermaid.R @@ -2,6 +2,7 @@ mermaid_init <- function( network, label = NULL, label_break = "
", + label_width = 60L, show_legend = TRUE, show_color = TRUE ) { @@ -9,6 +10,7 @@ mermaid_init <- function( network = network, label = label, label_break = label_break, + label_width = label_width, show_legend = show_legend, show_color = show_color ) @@ -18,6 +20,7 @@ mermaid_new <- function( network = NULL, label = NULL, label_break = NULL, + label_width = NULL, show_legend = NULL, show_color = NULL ) { @@ -25,6 +28,7 @@ mermaid_new <- function( network = network, label = label, label_break = label_break, + label_width = label_width, show_legend = show_legend, show_color = show_color ) @@ -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 diff --git a/R/tar_mermaid.R b/R/tar_mermaid.R index b3339691..6639db2b 100644 --- a/R/tar_mermaid.R +++ b/R/tar_mermaid.R @@ -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 @@ -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"), @@ -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) @@ -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, @@ -108,6 +113,7 @@ tar_mermaid_inner <- function( exclude_quosure, outdated, label, + label_width, legend, color, reporter, @@ -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 ) diff --git a/man/tar_mermaid.Rd b/man/tar_mermaid.Rd index a7100ad5..a3654669 100644 --- a/man/tar_mermaid.Rd +++ b/man/tar_mermaid.Rd @@ -11,7 +11,8 @@ tar_mermaid( 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"), @@ -70,11 +71,15 @@ and setting \code{outdated} to \code{FALSE} is a nice way to speed up the graph if you only want to see dependency relationships and pipeline progress.} \item{label}{Character vector of one or more aesthetics to add to the -vertex labels. Can contain \code{"time"} to show total runtime, \code{"size"} +vertex labels. Can contain \code{"description"} to show each +target's custom description, \code{"time"} to show total runtime, \code{"size"} to show total storage size, or \code{"branches"} to show the number of branches in each pattern. You can choose multiple aesthetics -at once, e.g. \code{label = c("time", "branches")}. All are disabled -by default because they clutter the graph.} +at once, e.g. \code{label = c("description", "time")}. +Only the description is enabled by default} + +\item{label_width}{Positive numeric of length 1, maximum width +(in number of characters) of the node labels.} \item{legend}{Logical of length 1, whether to display the legend.} @@ -210,7 +215,7 @@ tar_script({ 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 diff --git a/man/tar_visnetwork.Rd b/man/tar_visnetwork.Rd index fbf90e96..21ce69c2 100644 --- a/man/tar_visnetwork.Rd +++ b/man/tar_visnetwork.Rd @@ -74,11 +74,12 @@ and setting \code{outdated} to \code{FALSE} is a nice way to speed up the graph if you only want to see dependency relationships and pipeline progress.} \item{label}{Character vector of one or more aesthetics to add to the -vertex labels. Can contain \code{"time"} to show total runtime, \code{"size"} +vertex labels. Can contain \code{"description"} to show each +target's custom description, \code{"time"} to show total runtime, \code{"size"} to show total storage size, or \code{"branches"} to show the number of branches in each pattern. You can choose multiple aesthetics -at once, e.g. \code{label = c("time", "branches")}. All are disabled -by default because they clutter the graph.} +at once, e.g. \code{label = c("description", "time")}. +Only the description is enabled by default} \item{label_width}{Positive numeric of length 1, maximum width (in number of characters) of the node labels.}