Create a VizModules Figure Builder Application
Source:R/figureBuilder_module_app.R
figureBuilderApp.RdBuild the multi-panel Figure Builder Shiny application as a returnable
object. The app lets users add any VizModules plot module to a free-form A4
canvas, drag and resize each plot, filter each plot's data independently,
label panels automatically, and export the whole figure as a single editable
SVG (or bundle every plot's source data, HTML plot, and statistics into one
.zip).
Usage
figureBuilderApp(
data_list = NULL,
module_registry = NULL,
title = "VizModules Figure Builder",
return_components = FALSE
)Arguments
- data_list
An optional named list of data frames that seed the dataset registry. If
NULL(the default), the bundled example datasets (plus asales_by_regionsummary suited to the pie plot) are used. At least one element is required. An element is either a data frame, or a named list of data frames for a module that needs companion tables (theComplexHeatmapmodule'slist(matrix = , column_annotations = )); in the latter case only the primary table is filtered and shown in the panel's table pane.- module_registry
An optional named list describing the plot modules to offer. If
NULL(the default), all bundled VizModules modules are offered, each opening on the same example figure as inmoduleGalleryApp(). Each entry is itself a list with components:label(character, shown in the picker),dataset(character, the dataset name itsdefaultswere written for),inputs_ui,output_ui, andserver_fn(the module's three functions), anddefaults(a named list of input defaults applied only whendatasetis the chosen dataset). An entry may also carryprimary.table, naming which table of a multi-table dataset gets filtered (the first by default); its presence is also what marks the module as able to take a multi-table dataset at all, so modules without it are handed the primary table alone and any dataset stays usable with any module. SeefigureBuilderServer()for thevector_svghook that lets a non-plotly module take part in the SVG figure export.- title
A character string used as the page title and header (default:
"VizModules Figure Builder").- return_components
Logical. When
FALSE(the default) ashiny::shinyApp()object is returned. WhenTRUEa named list withuiandserverelements is returned instead, which is convenient for deployment scripts that need an explicitshinyApp(ui, server)call.
Value
Either a shiny::shinyApp() object, or (when
return_components = TRUE) a list with elements ui and server.
Details
Datasets are supplied via data_list and seed the "Add Plot" dialog; users
can also upload additional datasets (CSV, TSV, or tab-delimited TXT) at runtime. The
set of available plot modules is controlled by module_registry, so the app
can be extended with custom wrapper modules without editing the package.
This is the recommended way to launch a standalone Figure Builder. Internally
it is a thin wrapper around the figureBuilderUI() / figureBuilderServer()
Shiny module, so the same builder can be embedded inside a larger app (and
instantiated more than once) by calling those two functions directly. It is
also the Figure Builder tab of moduleGalleryApp().
Examples
library(VizModules)
# Launch with the bundled example datasets and all modules:
app <- figureBuilderApp()
if (interactive()) runApp(app)
# Launch with your own datasets:
app2 <- figureBuilderApp(data_list = list("iris" = iris, "mtcars" = mtcars))
if (interactive()) runApp(app2)
# Return the UI and server separately (e.g. for a deployment app.R):
parts <- figureBuilderApp(return_components = TRUE)
if (interactive()) shinyApp(parts$ui, parts$server)