R/app_module_cf_plot.R

Defines functions ie_cf_plot_server ie_cf_plot_ui

Documented in ie_cf_plot_server ie_cf_plot_ui

#' Continuous flow plot module
#'
#' A plot view for continuous flow trace data, wired to a [ie_file_server()]: it
#' plots the selection-filtered aggregated `traces` with
#' [isoreader2::ir_plot_traces()], with unit, species/mass, legend, zoom
#' and PDF-download controls. Pair `ie_cf_plot_ui()` and `ie_cf_plot_server()` on one `id`.
#'
#' @inheritParams ie_metadata_server
#' @param file the [ie_file_server()] handle
#' @return `ie_cf_plot_ui()` returns a UI element; `ie_cf_plot_server()` returns a
#'   list with a `get_code` generator for the code server (see [ie_code_server()])
#' @seealso [ie_file_server()], [ie_cf_metadata_server()]
#' @name ie_cf_plot
#' @examples
#' if (interactive()) {
#'   library(shiny)
#'   iso <-
#'     isoreader2::ir_examples_folder() |>
#'     isoreader2::ir_find_isofiles() |>
#'     isoreader2::ir_read_isofiles()
#'
#'   ui <- ie_type_explorer_ui("meta", ie_cf_plot_ui("cf"))
#'   server <- function(input, output, session) {
#'     file <- ie_file_server("files", get_isofiles = reactive(iso))
#'     ie_cf_metadata_server("meta", file)
#'     ie_cf_plot_server("cf", file)
#'   }
#'   shinyApp(ui, server)
#' }
#' @export
ie_cf_plot_ui <- function(id) {
  ns <- NS(id)
  data_plot_view_ui(
    id,
    # short_time_labels is a continuous-flow-only ir_plot_traces() option
    extra_options = checkboxInput(
      ns("short_time_labels"),
      "Short time labels",
      value = FALSE
    )
  )
}

#' @rdname ie_cf_plot
#' @export
ie_cf_plot_server <- function(id, file) {
  setup_data_plot(
    id,
    get_data = file$get_aggregated_cf_data,
    get_units = file$get_units,
    set_units = file$set_units,
    dataset_key = "traces",
    plot_fn = isoreader2::ir_plot_traces,
    plot_fn_name = "ir_plot_traces",
    no_data_message = "No continuous flow trace data selected/available.",
    download_basename = "continuous_flow",
    zoom_arg = "time_window.s",
    get_selection = file$get_cf_selection,
    get_all_metadata = file$get_cf_metadata
  )
}

Try the isoexplorer package in your browser

Any scripts or data that you put into this service are public.

isoexplorer documentation built on Sept. 8, 2026, 1:07 a.m.