Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

289 xaxis lab for Line Plot & Spaghetti Plot #320

Closed
wants to merge 8 commits into from
10 changes: 9 additions & 1 deletion R/tm_g_gh_lineplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#' @param dot_size plot dot size.
#' @param plot_relative_height_value numeric value between 500 and 5000 for controlling the starting value
#' of the relative plot height slider
#' @param xlab an x-axis label, if \code{NULL} then the behavior as in `xlab` from \link[goshawk]{g_lineplot}
#' @author Wenyi Liu (luiw2) [email protected]
#' @author Balazs Toth (tothb2) [email protected]
#'
Expand Down Expand Up @@ -147,6 +148,7 @@ tm_g_gh_lineplot <- function(label,
)[1:4],
xtick = ggplot2::waiver(),
xlabel = xtick,
xlab = "Analysis Visit",
rotate_xlab = FALSE,
plot_height = c(600, 200, 4000),
plot_width = NULL,
Expand Down Expand Up @@ -201,6 +203,9 @@ tm_g_gh_lineplot <- function(label,
# Validate line arguments
validate_line_arb_arg(hline_arb, hline_arb_color, hline_arb_label)

# Validate character labels
checkmate::assert_string(xlab, null.ok = TRUE)

args <- as.list(environment())

module(
Expand Down Expand Up @@ -277,7 +282,8 @@ ui_lineplot <- function(id, ...) {
value = c(-1000000, 1000000)
),
checkboxInput(ns("rotate_xlab"), "Rotate X-axis Label", a$rotate_xlab),
numericInput(ns("count_threshold"), "Contributing Observations Threshold:", a$count_threshold)
numericInput(ns("count_threshold"), "Contributing Observations Threshold:", a$count_threshold),
textInput(ns("xlab"), "X-axis Label", a$xlab)
),
teal.widgets::panel_item(
title = "Plot settings",
Expand Down Expand Up @@ -720,6 +726,7 @@ srv_lineplot <- function(id,
"
)
}
xlab <- if (is.null(input$xlab)) xaxis else input$xlab

hline_arb <- horizontal_line()$line_arb
hline_arb_label <- horizontal_line()$line_arb_label
Expand Down Expand Up @@ -749,6 +756,7 @@ srv_lineplot <- function(id,
hline_arb_color = .(hline_arb_color),
xtick = .(if (!is.null(xtick)) quote(xtick) else xtick),
xlabel = .(if (!is.null(xtick)) quote(xlabel) else xlabel),
xlab = .(xlab),
rotate_xlab = .(rotate_xlab),
plot_height = .(relative_height), # in g_lineplot this is relative height of plot to table
plot_font_size = .(plot_font_size),
Expand Down
9 changes: 9 additions & 0 deletions R/tm_g_gh_spaghettiplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#' @param hline_vars_colors a character vector naming the colors for the additional horizontal lines.
#' @param hline_vars_labels a character vector naming the labels for the additional horizontal lines that will appear
#' in the legend.
#' @param xlab an `x-axis` label, if \code{NULL} then no label is displayed
#' @inheritParams teal.widgets::standard_layout
#'
#' @author Wenyi Liu (luiw2) [email protected]
Expand Down Expand Up @@ -176,6 +177,7 @@ tm_g_gh_spaghettiplot <- function(label,
color_comb = NULL,
xtick = ggplot2::waiver(),
xlabel = xtick,
xlab = "Analysis Visit",
rotate_xlab = FALSE,
facet_ncol = 2,
free_x = FALSE,
Expand Down Expand Up @@ -236,6 +238,9 @@ tm_g_gh_spaghettiplot <- function(label,
validate_line_arb_arg(hline_arb, hline_arb_color, hline_arb_label)
validate_line_vars_arg(hline_vars, hline_vars_colors, hline_vars_labels)

# Validate character labels
checkmate::assert_string(xlab, null.ok = TRUE)

args <- as.list(environment())

module(
Expand Down Expand Up @@ -320,6 +325,7 @@ g_ui_spaghettiplot <- function(id, ...) {
),
checkboxInput(ns("free_x"), "Free X-Axis Scales", a$free_x),
checkboxInput(ns("rotate_xlab"), "Rotate X-Axis Label", a$rotate_xlab),
textInput(ns("xlab"), "X-axis Label", a$xlab),
teal.widgets::optionalSliderInputValMinMax(ns("font_size"), "Font Size", a$font_size, ticks = FALSE),
teal.widgets::optionalSliderInputValMinMax(ns("dot_size"), "Dot Size", a$dot_size, ticks = FALSE),
teal.widgets::optionalSliderInputValMinMax(
Expand Down Expand Up @@ -474,6 +480,8 @@ srv_g_spaghettiplot <- function(id,
)
}

xlab <- input$xlab

teal.code::eval_code(
object = private_qenv,
code = bquote({
Expand All @@ -498,6 +506,7 @@ srv_g_spaghettiplot <- function(id,
hline_arb_color = .(hline_arb_color),
xtick = xtick,
xlabel = xlabel,
xlab = .(xlab),
rotate_xlab = .(rotate_xlab),
font_size = .(font_size),
dot_size = .(dot_size),
Expand Down
3 changes: 3 additions & 0 deletions man/tm_g_gh_lineplot.Rd

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

3 changes: 3 additions & 0 deletions man/tm_g_gh_spaghettiplot.Rd

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

Loading