Skip to content

Commit

Permalink
pre-release tm_g_scatterplot document update (#657)
Browse files Browse the repository at this point in the history
part of
#624
  • Loading branch information
kartikeyakirar authored Feb 26, 2024
1 parent d5fbe8c commit 33714ae
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 59 deletions.
68 changes: 34 additions & 34 deletions R/tm_g_scatterplot.R
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
#' Create a simple scatterplot
#'
#' Create a plot with the \code{\link{ggplot2}[geom_point]} function
#' @md
#'
#' @inheritParams teal::module
#' @inheritParams shared_params
#' @param x (`data_extract_spec` or `list` of multiple `data_extract_spec`) Variable
#' names selected to plot along the x-axis by default.
#' @param y (`data_extract_spec` or `list` of multiple `data_extract_spec`) Variable
#' names selected to plot along the y-axis by default.
#' @param color_by optional (`data_extract_spec` or `list` of multiple `data_extract_spec`)
#' Defines the color encoding. If `NULL` then no color encoding option will be displayed.
#' @param size_by optional (`data_extract_spec` or `list` of multiple `data_extract_spec`)
#' Defines the point size encoding. If `NULL` then no size encoding option will be displayed.
#' @param row_facet optional, (`data_extract_spec` or `list` of multiple `data_extract_spec`)
#' Which data columns to use for faceting rows.
#' @param col_facet optional, (`data_extract_spec` or `list` of multiple `data_extract_spec`)
#' Which data to use for faceting columns.
#' @param alpha optional, (`numeric`) If scalar then the plot points will have a fixed opacity. If a
#' slider should be presented to adjust the plot point opacity dynamically then it can be a vector of
#' length three with `c(value, min, max)`.
#' @param size optional, (`numeric`) If scalar then the plot point sizes will have a fixed size
#' If a slider should be presented to adjust the plot point sizes dynamically then it can be a
#' vector of length three with `c(value, min, max)`.
#' @param shape optional, (`character`) A character vector with the English names of the
#' shape, e.g. `c("triangle", "square", "circle")`. It defaults to `shape_names`. This is a complete list from
#' `vignette("ggplot2-specs", package="ggplot2")`.
#' @param max_deg optional, (`integer`) The maximum degree for the polynomial trend line. Must not be less than 1.
#' @param table_dec optional, (`integer`) Number of decimal places used to round numeric values in the table.
#' Scatterplot module
#'
#' Generates a customizable scatterplot using `ggplot2`.
#' This module allows users to select variables for the x and y axes,
#' color and size encodings, faceting options, and more. It supports log transformations,
#' trend line additions, and dynamic adjustments of point opacity and size through UI controls.
#'
#' @note For more examples, please see the vignette "Using scatterplot" via
#' `vignette("using-scatterplot", package = "teal.modules.general")`.
#'
#' @inheritParams teal::module
#' @inheritParams shared_params
#' @param x (`data_extract_spec` or `list` of multiple `data_extract_spec`) Specifies
#' variable names selected to plot along the x-axis by default.
#' @param y (`data_extract_spec` or `list` of multiple `data_extract_spec`) Specifies
#' variable names selected to plot along the y-axis by default.
#' @param color_by (`data_extract_spec` or `list` of multiple `data_extract_spec`, optional)
#' Defines the color encoding. If `NULL` then no color encoding option will be displayed.
#' @param size_by (`data_extract_spec` or `list` of multiple `data_extract_spec`, optional)
#' Defines the point size encoding. If `NULL` then no size encoding option will be displayed.
#' @param row_facet (`data_extract_spec` or `list` of multiple `data_extract_spec`, optional)
#' Specifies the variable(s) for faceting rows.
#' @param col_facet (`data_extract_spec` or `list` of multiple `data_extract_spec`, optional)
#' Specifies the variable(s) for faceting columns.
#' @param alpha (`numeric`, optional) Specifies point opacity.
#' - If vector of `length == 1` then the plot points will have a fixed opacity.
#' - while vector of `value`, `min`, and `max` allows dynamic adjustment.
#' @param size (`numeric`, optional) Specifies point size.
#' - If vector of `length == 1` then the plot point sizes will have a fixed size
#' - while vector of `value`, `min`, and `max` allows dynamic adjustment.
#' @param shape (`character`, optional) A character vector with the names of the
#' shape, e.g. `c("triangle", "square", "circle")`. It defaults to `shape_names`. This is a complete list from
#' `vignette("ggplot2-specs", package="ggplot2")`.
#' @param max_deg (`integer`, optional) The maximum degree for the polynomial trend line. Must not be less than 1.
#' @param table_dec (`integer`, optional) Number of decimal places used to round numeric values in the table.
#'
#' @examples
#' # general data example
#' library(teal.widgets)
#'
#' # general data example
#' data <- teal_data()
#' data <- within(data, {
#' require(nestcolor)
Expand Down Expand Up @@ -122,10 +123,7 @@
#' shinyApp(app$ui, app$server)
#' }
#'
#'
#' # CDISC data example
#' library(teal.widgets)
#'
#' data <- teal_data()
#' data <- within(data, {
#' require(nestcolor)
Expand Down Expand Up @@ -320,6 +318,7 @@ tm_g_scatterplot <- function(label = "Scatterplot",
)
}

# UI function for the scatterplot module
ui_g_scatterplot <- function(id, ...) {
args <- list(...)
ns <- NS(id)
Expand Down Expand Up @@ -471,6 +470,7 @@ ui_g_scatterplot <- function(id, ...) {
)
}

# Server function for the scatterplot module
srv_g_scatterplot <- function(id,
data,
reporter,
Expand Down
54 changes: 29 additions & 25 deletions man/tm_g_scatterplot.Rd

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

0 comments on commit 33714ae

Please sign in to comment.