Drop-in replacement for shiny::renderPlot() that automatically
detects container width, computes a scale factor, and injects it via
withr::with_options() so that av_theme_alpha() and
.av_scaled_size() respond without any signature changes.
Arguments
- output_id
Character. The Shiny output id (e.g.
"dashboard_interval"). Used to querysession$clientDatafor the rendered width.- expr
An expression producing a ggplot object. Captured via
substitute(); evaluated inside the scoped options context.- height
Height specification. Either a fixed integer (pixels), a function returning an integer (for reactive/dynamic height), or
NULLfor the default of 500px.
Value
A shiny::renderPlot() output.
Examples
example_file <- system.file(
"extdata", "bcl11a_rs1427407_example.csv", package = "AlphaVaR"
)
obj <- av_import_csv(example_file)
#> Reading bcl11a_rs1427407_example.csv ...
# In a Shiny server the result is assigned to output$dashboard_density.
# The plot expression is captured unevaluated and only runs once Shiny
# renders the output, with av_scale_factor set from the container width.
renderer <- render_av_plot(
"dashboard_density",
av_plot_distribution(obj, style = "density", group_by = "output_type"),
height = .av_estimate_height(obj, base_height = 200L, per_element = 150L)
)
class(renderer)
#> [1] "shiny.renderPlot" "shiny.render.function" "function"