| Type: | Package |
| Title: | Multimodal Access and Interactive Data Representation |
| Version: | 0.1.2 |
| URL: | https://github.com/xability/r-maidr, https://r.maidr.ai/ |
| BugReports: | https://github.com/xability/r-maidr/issues |
| Description: | Provides accessible, interactive visualizations through the 'MAIDR' (Multimodal Access and Interactive Data Representation) system. Converts 'ggplot2' and Base R plots into accessible HTML/SVG formats with keyboard navigation, screen reader support, and 'sonification' capabilities. Supports bar charts (simple, grouped, stacked), histograms, line plots, scatter plots, box plots, heat maps, density/smooth curves, faceted plots, multi-panel layouts (including patchwork), and multi-layered plot combinations. Enables data exploration for users with visual impairments through multiple sensory modalities. For more details see the 'MAIDR' project https://maidr.ai/. |
| License: | GPL (≥ 3) |
| Encoding: | UTF-8 |
| Imports: | base64enc, curl, ggplot2, ggplotify, grid, gridSVG, htmltools, htmlwidgets, jsonlite, shiny, xml2, rlang, R6 |
| Suggests: | testthat (≥ 3.0.0), lintr, styler, goodpractice, cyclocomp, knitr, rmarkdown, patchwork |
| Config/testthat/edition: | 3 |
| RoxygenNote: | 7.3.2 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2026-02-18 20:43:48 UTC; niranjank |
| Author: | JooYoung Seo [aut, cph], Niranjan Kalaiselvan [aut, cre] |
| Maintainer: | Niranjan Kalaiselvan <nk46@illinois.edu> |
| Repository: | CRAN |
| Date/Publication: | 2026-02-23 09:30:07 UTC |
Base R Function Classification
Description
Maps of function names to their classification levels
Usage
.base_r_function_classes
Format
An object of class list of length 3.
Details
This module classifies Base R plotting functions into categories: - HIGH: Main plot creation functions (barplot, hist, plot, etc.) - LOW: Drawing functions that add to existing plots (lines, points, etc.) - LAYOUT: Canvas layout functions (par, layout, etc.)
Base R Device-Scoped Storage
Description
This module provides device-scoped storage for Base R plot calls, enabling proper isolation between devices and preventing call accumulation.
Usage
.maidr_base_r_session
Format
An object of class environment of length 2.
Base R Function Patching System
Description
This module provides function patching capabilities for Base R plotting functions. It intercepts Base R plotting calls and records them for processing by the MAIDR system.
Usage
.maidr_patching_env
Format
An object of class environment of length 4.
Base R System Adapter
Description
Adapter for the Base R plotting system. This adapter uses function patching to intercept Base R plotting calls and detect plot types.
Format
An R6 class inheriting from SystemAdapter
Super class
maidr::SystemAdapter -> BaseRAdapter
Methods
Public methods
Method new()
Usage
BaseRAdapter$new()
Method can_handle()
Usage
BaseRAdapter$can_handle(plot_object)
Arguments
plot_objectThe plot object to check (should be NULL for Base R)
Returns
TRUE if Base R plotting is active, FALSE otherwise Detect the type of a single layer from Base R plot calls
Method detect_layer_type()
Usage
BaseRAdapter$detect_layer_type(layer, plot_object = NULL)
Arguments
layerThe plot call entry from our logger
plot_objectThe parent plot object (NULL for Base R)
Returns
String indicating the layer type (e.g., "bar", "dodged_bar", "stacked_bar", "smooth", "line", "point") Check if a barplot call represents a dodged bar plot
Method is_dodged_barplot()
Usage
BaseRAdapter$is_dodged_barplot(args)
Arguments
argsThe arguments from the barplot call
Returns
TRUE if this is a dodged bar plot, FALSE otherwise Check if a barplot call represents a stacked bar plot
Method is_stacked_barplot()
Usage
BaseRAdapter$is_stacked_barplot(args)
Arguments
argsThe arguments from the barplot call
Returns
TRUE if this is a stacked bar plot, FALSE otherwise Create an orchestrator for this system (Base R)
Method create_orchestrator()
Usage
BaseRAdapter$create_orchestrator(plot_object = NULL)
Arguments
plot_objectThe plot object to process (NULL for Base R)
Returns
PlotOrchestrator instance Get the system name
Method get_system_name()
Usage
BaseRAdapter$get_system_name()
Returns
System name string Get a reference to this adapter (for use by orchestrator)
Method get_adapter()
Usage
BaseRAdapter$get_adapter()
Returns
Self reference Check if plot has facets (Base R doesn't support facets)
Method has_facets()
Usage
BaseRAdapter$has_facets(plot_object = NULL)
Arguments
plot_objectThe plot object (ignored for Base R)
Returns
FALSE (Base R doesn't support facets) Check if plot is a patchwork plot (Base R doesn't support patchwork)
Method is_patchwork()
Usage
BaseRAdapter$is_patchwork(plot_object = NULL)
Arguments
plot_objectThe plot object (ignored for Base R)
Returns
FALSE (Base R doesn't support patchwork) Get recorded plot calls for processing
Method get_plot_calls()
Usage
BaseRAdapter$get_plot_calls(device_id = grDevices::dev.cur())
Arguments
device_idGraphics device ID (defaults to current device)
Returns
List of recorded plot calls Clear recorded plot calls (for cleanup)
Method clear_plot_calls()
Usage
BaseRAdapter$clear_plot_calls(device_id = grDevices::dev.cur())
Arguments
device_idGraphics device ID (defaults to current device) Initialize function patching
Method initialize_patching()
Usage
BaseRAdapter$initialize_patching()
Returns
NULL (invisible) Restore original functions
Method restore_functions()
Usage
BaseRAdapter$restore_functions()
Returns
NULL (invisible)
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRAdapter$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Bar Plot Layer Processor
Description
Base R Bar Plot Layer Processor
Base R Bar Plot Layer Processor
Details
Processes Base R bar plot layers based on recorded plot calls
Super class
maidr::LayerProcessor -> BaseRBarplotLayerProcessor
Methods
Public methods
Inherited methods
Method process()
Usage
BaseRBarplotLayerProcessor$process( plot, layout, built = NULL, gt = NULL, scale_mapping = NULL, grob_id = NULL, panel_id = NULL, panel_ctx = NULL, layer_info = NULL )
Method needs_reordering()
Usage
BaseRBarplotLayerProcessor$needs_reordering()
Method extract_data()
Usage
BaseRBarplotLayerProcessor$extract_data(layer_info)
Method extract_axis_titles()
Usage
BaseRBarplotLayerProcessor$extract_axis_titles(layer_info)
Method extract_main_title()
Usage
BaseRBarplotLayerProcessor$extract_main_title(layer_info)
Method generate_selectors()
Usage
BaseRBarplotLayerProcessor$generate_selectors(layer_info, gt = NULL)
Method find_rect_grobs()
Recursively find rect grobs in the grob tree (like ggplot2 does)
Usage
BaseRBarplotLayerProcessor$find_rect_grobs(grob, call_index)
Arguments
grobThe grob tree to search
call_indexThe plot call index to match
Returns
Character vector of grob names
Method generate_selectors_from_grob()
Generate selectors from grob tree (like ggplot2 does)
Usage
BaseRBarplotLayerProcessor$generate_selectors_from_grob(grob, call_index)
Arguments
grobThe grob tree to search
call_indexThe plot call index
Returns
List of selectors
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRBarplotLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Boxplot Layer Processor
Description
Processes Base R boxplot layers by extracting statistical summaries and generating selectors for boxplot components.
Super class
maidr::LayerProcessor -> BaseRBoxplotLayerProcessor
Methods
Public methods
Inherited methods
maidr::LayerProcessor$apply_scale_mapping()maidr::LayerProcessor$extract_layer_axes()maidr::LayerProcessor$get_last_result()maidr::LayerProcessor$get_layer_index()maidr::LayerProcessor$initialize()maidr::LayerProcessor$needs_reordering()maidr::LayerProcessor$reorder_layer_data()maidr::LayerProcessor$set_last_result()
Method process()
Usage
BaseRBoxplotLayerProcessor$process( plot, layout, built = NULL, gt = NULL, layer_info = NULL )
Method extract_data()
Usage
BaseRBoxplotLayerProcessor$extract_data(layer_info)
Method generate_selectors()
Usage
BaseRBoxplotLayerProcessor$generate_selectors( layer_info, gt = NULL, extracted_data = NULL )
Method extract_axis_titles()
Usage
BaseRBoxplotLayerProcessor$extract_axis_titles(layer_info)
Method extract_main_title()
Usage
BaseRBoxplotLayerProcessor$extract_main_title(layer_info)
Method determine_orientation()
Usage
BaseRBoxplotLayerProcessor$determine_orientation(layer_info)
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRBoxplotLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Dodged Bar Layer Processor
Description
Processes Base R dodged bar plot layers with proper ordering to match backend logic
Super class
maidr::LayerProcessor -> BaseRDodgedBarLayerProcessor
Methods
Public methods
Inherited methods
maidr::LayerProcessor$apply_scale_mapping()maidr::LayerProcessor$extract_layer_axes()maidr::LayerProcessor$get_last_result()maidr::LayerProcessor$get_layer_index()maidr::LayerProcessor$initialize()maidr::LayerProcessor$needs_reordering()maidr::LayerProcessor$reorder_layer_data()maidr::LayerProcessor$set_last_result()
Method process()
Usage
BaseRDodgedBarLayerProcessor$process( plot, layout, built = NULL, gt = NULL, layer_info = NULL )
Method extract_data()
Usage
BaseRDodgedBarLayerProcessor$extract_data(layer_info)
Method generate_selectors()
Usage
BaseRDodgedBarLayerProcessor$generate_selectors(layer_info, gt = NULL)
Method find_rect_grobs()
Usage
BaseRDodgedBarLayerProcessor$find_rect_grobs(grob, call_index)
Method generate_selectors_from_grob()
Usage
BaseRDodgedBarLayerProcessor$generate_selectors_from_grob(grob, call_index)
Method extract_axis_titles()
Usage
BaseRDodgedBarLayerProcessor$extract_axis_titles(layer_info)
Method extract_main_title()
Usage
BaseRDodgedBarLayerProcessor$extract_main_title(layer_info)
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRDodgedBarLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Heatmap Layer Processor
Description
Processes Base R heatmap layers using the heatmap() function
Super class
maidr::LayerProcessor -> BaseRHeatmapLayerProcessor
Methods
Public methods
Inherited methods
maidr::LayerProcessor$apply_scale_mapping()maidr::LayerProcessor$extract_layer_axes()maidr::LayerProcessor$get_last_result()maidr::LayerProcessor$get_layer_index()maidr::LayerProcessor$initialize()maidr::LayerProcessor$needs_reordering()maidr::LayerProcessor$reorder_layer_data()maidr::LayerProcessor$set_last_result()
Method process()
Usage
BaseRHeatmapLayerProcessor$process( plot, layout, built = NULL, gt = NULL, scale_mapping = NULL, grob_id = NULL, panel_id = NULL, panel_ctx = NULL, layer_info = NULL )
Method extract_data()
Usage
BaseRHeatmapLayerProcessor$extract_data(layer_info)
Method generate_selectors()
Usage
BaseRHeatmapLayerProcessor$generate_selectors(layer_info, gt = NULL)
Method find_image_rect_grobs()
Usage
BaseRHeatmapLayerProcessor$find_image_rect_grobs(grob, group_index)
Method generate_selectors_from_grob()
Usage
BaseRHeatmapLayerProcessor$generate_selectors_from_grob( grob, group_index = NULL )
Method extract_axis_titles()
Usage
BaseRHeatmapLayerProcessor$extract_axis_titles(layer_info)
Method extract_main_title()
Usage
BaseRHeatmapLayerProcessor$extract_main_title(layer_info)
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRHeatmapLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Histogram Layer Processor
Description
Processes Base R histogram plot layers using verified data extraction and selector generation logic.
Super class
maidr::LayerProcessor -> BaseRHistogramLayerProcessor
Methods
Public methods
Inherited methods
maidr::LayerProcessor$apply_scale_mapping()maidr::LayerProcessor$extract_layer_axes()maidr::LayerProcessor$get_last_result()maidr::LayerProcessor$get_layer_index()maidr::LayerProcessor$initialize()maidr::LayerProcessor$needs_reordering()maidr::LayerProcessor$reorder_layer_data()maidr::LayerProcessor$set_last_result()
Method process()
Usage
BaseRHistogramLayerProcessor$process( plot, layout, built = NULL, gt = NULL, layer_info = NULL )
Method extract_data()
Usage
BaseRHistogramLayerProcessor$extract_data(layer_info)
Method generate_selectors()
Usage
BaseRHistogramLayerProcessor$generate_selectors(layer_info, gt = NULL)
Method find_rect_grobs()
Usage
BaseRHistogramLayerProcessor$find_rect_grobs(grob, call_index)
Method generate_selectors_from_grob()
Usage
BaseRHistogramLayerProcessor$generate_selectors_from_grob( grob, call_index = NULL )
Method extract_axis_titles()
Usage
BaseRHistogramLayerProcessor$extract_axis_titles(layer_info)
Method extract_main_title()
Usage
BaseRHistogramLayerProcessor$extract_main_title(layer_info)
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRHistogramLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Line Plot Layer Processor
Description
Processes Base R line plot layers based on recorded plot calls
Super class
maidr::LayerProcessor -> BaseRLineLayerProcessor
Methods
Public methods
Inherited methods
Method process()
Usage
BaseRLineLayerProcessor$process( plot, layout, built = NULL, gt = NULL, scale_mapping = NULL, grob_id = NULL, panel_id = NULL, panel_ctx = NULL, layer_info = NULL )
Method needs_reordering()
Usage
BaseRLineLayerProcessor$needs_reordering()
Method extract_data()
Usage
BaseRLineLayerProcessor$extract_data(layer_info)
Method get_axis_labels()
Usage
BaseRLineLayerProcessor$get_axis_labels(layer_info, axis_side = 1)
Arguments
layer_infoLayer information containing group data
axis_sideWhich axis (1=bottom/x, 2=left/y, 3=top, 4=right)
Returns
Character vector of labels or NULL if not found
Method extract_single_line_data()
Usage
BaseRLineLayerProcessor$extract_single_line_data(x, y, x_labels = NULL)
Method extract_multiline_data()
Usage
BaseRLineLayerProcessor$extract_multiline_data(x, y_matrix, x_labels = NULL)
Method extract_axis_titles()
Usage
BaseRLineLayerProcessor$extract_axis_titles(layer_info)
Method extract_abline_data()
Usage
BaseRLineLayerProcessor$extract_abline_data(layer_info)
Method get_x_range_from_group()
Usage
BaseRLineLayerProcessor$get_x_range_from_group(group)
Method get_y_range_from_group()
Usage
BaseRLineLayerProcessor$get_y_range_from_group(group)
Method extract_main_title()
Usage
BaseRLineLayerProcessor$extract_main_title(layer_info)
Method generate_selectors()
Usage
BaseRLineLayerProcessor$generate_selectors(layer_info, gt = NULL)
Method find_lines_grobs()
Usage
BaseRLineLayerProcessor$find_lines_grobs( grob, group_index, grob_type = "lines" )
Method generate_selectors_from_grob()
Usage
BaseRLineLayerProcessor$generate_selectors_from_grob( grob, group_index, layer_info )
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRLineLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Patch Architecture
Description
Modular system for patching Base R plotting functions with chain of responsibility pattern
Methods
Public methods
Method can_patch()
Usage
BaseRPatcher$can_patch(function_name, args)
Method apply_patch()
Usage
BaseRPatcher$apply_patch(function_name, args)
Method get_name()
Usage
BaseRPatcher$get_name()
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRPatcher$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Plot Orchestrator Class
Description
Base R Plot Orchestrator Class
Base R Plot Orchestrator Class
Details
This class orchestrates the detection and processing of multiple layers in Base R plots. It analyzes each recorded plot call individually and combines the results into a comprehensive interactive plot.
Public fields
plot_callsList of recorded Base R plot calls
layersList of detected layer information
layer_processorsList of layer-specific processors
combined_dataCombined data from all layers
combined_selectorsCombined selectors from all layers
layoutLayout information from the plot
Active bindings
plot_callsList of recorded Base R plot calls
layersList of detected layer information
layer_processorsList of layer-specific processors
combined_dataCombined data from all layers
combined_selectorsCombined selectors from all layers
layoutLayout information from the plot
Methods
Public methods
Method new()
Usage
BaseRPlotOrchestrator$new(device_id = grDevices::dev.cur())
Method detect_layers()
Usage
BaseRPlotOrchestrator$detect_layers()
Method analyze_single_layer()
Usage
BaseRPlotOrchestrator$analyze_single_layer( plot_call, layer_index, group = NULL )
Method create_layer_processors()
Usage
BaseRPlotOrchestrator$create_layer_processors()
Method create_layer_processor()
Usage
BaseRPlotOrchestrator$create_layer_processor(layer_info)
Method create_unified_layer_processor()
Usage
BaseRPlotOrchestrator$create_unified_layer_processor(layer_info)
Arguments
layer_infoLayer information
Returns
Layer processor instance Extract Format Configuration from axis() Calls
Scans logged axis() calls for format config stored by the axis wrapper. The wrapper stores .maidr_format_config when labels is a scales:: function.
Method process_layers()
Usage
BaseRPlotOrchestrator$process_layers()
Method extract_format_config_from_axis_calls()
Usage
BaseRPlotOrchestrator$extract_format_config_from_axis_calls()
Returns
A list with x and/or y format configurations, or NULL
Method extract_layout()
Usage
BaseRPlotOrchestrator$extract_layout()
Method combine_layer_results()
Usage
BaseRPlotOrchestrator$combine_layer_results(layer_results)
Method generate_maidr_data()
Usage
BaseRPlotOrchestrator$generate_maidr_data()
Method get_layout()
Usage
BaseRPlotOrchestrator$get_layout()
Method get_combined_data()
Usage
BaseRPlotOrchestrator$get_combined_data()
Method get_layer_processors()
Usage
BaseRPlotOrchestrator$get_layer_processors()
Method get_layers()
Usage
BaseRPlotOrchestrator$get_layers()
Method get_plot_calls()
Usage
BaseRPlotOrchestrator$get_plot_calls()
Method get_gtable()
Usage
BaseRPlotOrchestrator$get_gtable()
Method get_grob_for_layer()
Usage
BaseRPlotOrchestrator$get_grob_for_layer(layer_index)
Method has_unsupported_layers()
Check if any HIGH-level layers are unsupported (unknown type)
Usage
BaseRPlotOrchestrator$has_unsupported_layers()
Returns
Logical indicating if there are unsupported layers
Method should_fallback()
Determine if the plot should fall back to image rendering
Usage
BaseRPlotOrchestrator$should_fallback()
Returns
Logical indicating if fallback should be used
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRPlotOrchestrator$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Point/Scatter Plot Layer Processor
Description
Processes Base R scatter plot layers based on recorded plot calls
Super class
maidr::LayerProcessor -> BaseRPointLayerProcessor
Methods
Public methods
Inherited methods
Method process()
Usage
BaseRPointLayerProcessor$process( plot, layout, built = NULL, gt = NULL, scale_mapping = NULL, grob_id = NULL, panel_id = NULL, panel_ctx = NULL, layer_info = NULL )
Method needs_reordering()
Usage
BaseRPointLayerProcessor$needs_reordering()
Method extract_data()
Usage
BaseRPointLayerProcessor$extract_data(layer_info)
Method extract_axis_titles()
Usage
BaseRPointLayerProcessor$extract_axis_titles(layer_info)
Method extract_main_title()
Usage
BaseRPointLayerProcessor$extract_main_title(layer_info)
Method generate_selectors()
Usage
BaseRPointLayerProcessor$generate_selectors(layer_info, gt = NULL)
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRPointLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Processor Factory
Description
Factory for creating Base R-specific processors. This factory creates processors for Base R plot types based on recorded plot calls.
Format
An R6 class inheriting from ProcessorFactory
Super class
maidr::ProcessorFactory -> BaseRProcessorFactory
Methods
Public methods
Inherited methods
Method new()
Usage
BaseRProcessorFactory$new()
Method create_processor()
Usage
BaseRProcessorFactory$create_processor(plot_type, layer_info)
Arguments
plot_typeThe type of plot (e.g., "bar", "line", "point")
layer_infoInformation about the layer (contains plot call and metadata)
Returns
Processor instance for the specified plot type Get list of supported plot types
Method get_supported_types()
Usage
BaseRProcessorFactory$get_supported_types()
Returns
Character vector of supported plot types Get the system name
Method get_system_name()
Usage
BaseRProcessorFactory$get_system_name()
Returns
System name string Check if a specific processor class is available
Method is_processor_available()
Usage
BaseRProcessorFactory$is_processor_available(processor_class_name)
Arguments
processor_class_nameName of the processor class
Returns
TRUE if available, FALSE otherwise Get available processor classes
Method get_available_processors()
Usage
BaseRProcessorFactory$get_available_processors()
Returns
Character vector of available processor class names Create a processor with error handling
Method try_create_processor()
Usage
BaseRProcessorFactory$try_create_processor(plot_type, layer_info)
Arguments
plot_typeThe type of plot
layer_infoThe layer information
Returns
Processor instance or NULL if creation fails
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRProcessorFactory$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Smooth/Density Layer Processor
Description
Processes Base R smooth curves including: - Density plots: plot(density()) or lines(density()) - Loess smooth: lines(loess.smooth()) or lines(predict(loess)) - Smooth splines: lines(smooth.spline())
Super class
maidr::LayerProcessor -> BaseRSmoothLayerProcessor
Methods
Public methods
Inherited methods
maidr::LayerProcessor$apply_scale_mapping()maidr::LayerProcessor$extract_layer_axes()maidr::LayerProcessor$get_last_result()maidr::LayerProcessor$get_layer_index()maidr::LayerProcessor$initialize()maidr::LayerProcessor$needs_reordering()maidr::LayerProcessor$reorder_layer_data()maidr::LayerProcessor$set_last_result()
Method process()
Usage
BaseRSmoothLayerProcessor$process( plot, layout, built = NULL, gt = NULL, scale_mapping = NULL, grob_id = NULL, panel_id = NULL, panel_ctx = NULL, layer_info = NULL )
Method extract_data()
Usage
BaseRSmoothLayerProcessor$extract_data(layer_info)
Method generate_selectors()
Usage
BaseRSmoothLayerProcessor$generate_selectors(layer_info, gt = NULL)
Method find_polyline_grobs()
Usage
BaseRSmoothLayerProcessor$find_polyline_grobs(grob, call_index = NULL)
Method generate_selectors_from_grob()
Usage
BaseRSmoothLayerProcessor$generate_selectors_from_grob(grob, call_index = NULL)
Method extract_axis_titles()
Usage
BaseRSmoothLayerProcessor$extract_axis_titles(layer_info)
Method extract_main_title()
Usage
BaseRSmoothLayerProcessor$extract_main_title(layer_info)
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRSmoothLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Stacked Bar Layer Processor
Description
Processes Base R stacked bar plot layers intercepted via the patching system. Assumes sorting by x (columns) and then fill (rows) has already been applied by the 'SortingPatcher'.
Super class
maidr::LayerProcessor -> BaseRStackedBarLayerProcessor
Methods
Public methods
Inherited methods
Method process()
Usage
BaseRStackedBarLayerProcessor$process( plot, layout, built = NULL, gt = NULL, scale_mapping = NULL, grob_id = NULL, panel_id = NULL, panel_ctx = NULL, layer_info = NULL )
Method needs_reordering()
Usage
BaseRStackedBarLayerProcessor$needs_reordering()
Method extract_data()
Usage
BaseRStackedBarLayerProcessor$extract_data(layer_info)
Method extract_axis_titles()
Usage
BaseRStackedBarLayerProcessor$extract_axis_titles(layer_info)
Method extract_main_title()
Usage
BaseRStackedBarLayerProcessor$extract_main_title(layer_info)
Method generate_selectors()
Usage
BaseRStackedBarLayerProcessor$generate_selectors(layer_info, gt = NULL)
Method find_rect_groups()
Usage
BaseRStackedBarLayerProcessor$find_rect_groups(grob, call_index)
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRStackedBarLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Base R Unknown Layer Processor
Description
Processes unknown Base R layer types as a fallback
Super class
maidr::LayerProcessor -> BaseRUnknownLayerProcessor
Methods
Public methods
Inherited methods
Method process()
Usage
BaseRUnknownLayerProcessor$process( plot, layout, built = NULL, gt = NULL, scale_mapping = NULL, grob_id = NULL, panel_id = NULL, panel_ctx = NULL, layer_info = NULL )
Method needs_reordering()
Usage
BaseRUnknownLayerProcessor$needs_reordering()
Method extract_data()
Usage
BaseRUnknownLayerProcessor$extract_data(layer_info)
Method generate_selectors()
Usage
BaseRUnknownLayerProcessor$generate_selectors(layer_info)
Method clone()
The objects of this class are cloneable with this method.
Usage
BaseRUnknownLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
ggplot2 System Adapter
Description
Adapter for the ggplot2 plotting system. This adapter wraps the existing ggplot2 functionality to work with the new extensible architecture.
Format
An R6 class inheriting from SystemAdapter
Super class
maidr::SystemAdapter -> Ggplot2Adapter
Methods
Public methods
Method new()
Usage
Ggplot2Adapter$new()
Method can_handle()
Usage
Ggplot2Adapter$can_handle(plot_object)
Arguments
plot_objectThe plot object to check
Returns
TRUE if this adapter can handle the object, FALSE otherwise Detect the type of a single layer
Method detect_layer_type()
Usage
Ggplot2Adapter$detect_layer_type(layer, plot_object)
Arguments
layerThe ggplot2 layer object to analyze
plot_objectThe parent plot object (for context)
Returns
String indicating the layer type (e.g., "bar", "line", "point") Create an orchestrator for this system (ggplot2)
Method create_orchestrator()
Usage
Ggplot2Adapter$create_orchestrator(plot_object)
Arguments
plot_objectThe ggplot2 plot object to process
Returns
PlotOrchestrator instance Get the system name
Method get_system_name()
Usage
Ggplot2Adapter$get_system_name()
Returns
System name string Get a reference to this adapter (for use by orchestrator)
Method get_adapter()
Usage
Ggplot2Adapter$get_adapter()
Returns
Self reference Check if plot has facets
Method has_facets()
Usage
Ggplot2Adapter$has_facets(plot_object)
Arguments
plot_objectThe ggplot2 plot object
Returns
TRUE if plot has facets, FALSE otherwise Check if plot is a patchwork plot
Method is_patchwork()
Usage
Ggplot2Adapter$is_patchwork(plot_object)
Arguments
plot_objectThe ggplot2 plot object
Returns
TRUE if plot is patchwork, FALSE otherwise
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2Adapter$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Bar Layer Processor
Description
Processes bar plot layers with complete logic included
Super class
maidr::LayerProcessor -> Ggplot2BarLayerProcessor
Methods
Public methods
Inherited methods
Method process()
Usage
Ggplot2BarLayerProcessor$process( plot, layout, built = NULL, gt = NULL, scale_mapping = NULL, grob_id = NULL, panel_id = NULL, panel_ctx = NULL )
Method needs_reordering()
Usage
Ggplot2BarLayerProcessor$needs_reordering()
Method reorder_layer_data()
Usage
Ggplot2BarLayerProcessor$reorder_layer_data(data, plot)
Method extract_data()
Usage
Ggplot2BarLayerProcessor$extract_data( plot, built = NULL, scale_mapping = NULL, panel_id = NULL )
Method generate_selectors()
Usage
Ggplot2BarLayerProcessor$generate_selectors( plot, gt = NULL, grob_id = NULL, panel_ctx = NULL )
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2BarLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Boxplot Layer Processor
Description
Processes boxplot layers (geom_boxplot) to extract statistical data and generate selectors for individual boxplot components in the SVG structure.
Super class
maidr::LayerProcessor -> Ggplot2BoxplotLayerProcessor
Methods
Public methods
Inherited methods
maidr::LayerProcessor$apply_scale_mapping()maidr::LayerProcessor$extract_layer_axes()maidr::LayerProcessor$get_last_result()maidr::LayerProcessor$get_layer_index()maidr::LayerProcessor$initialize()maidr::LayerProcessor$needs_reordering()maidr::LayerProcessor$reorder_layer_data()maidr::LayerProcessor$set_last_result()
Method process()
Usage
Ggplot2BoxplotLayerProcessor$process(plot, layout, built = NULL, gt = NULL)
Arguments
plotThe ggplot2 object
layoutLayout information
builtBuilt plot data (optional)
gtGtable object (optional)
Returns
List with data and selectors Extract data from boxplot layer
Method extract_data()
Usage
Ggplot2BoxplotLayerProcessor$extract_data(plot, built = NULL)
Arguments
plotThe ggplot2 object
builtBuilt plot data (optional)
Returns
List with boxplot statistics for each category Generate selectors for boxplot elements
Method generate_selectors()
Usage
Ggplot2BoxplotLayerProcessor$generate_selectors(plot, gt = NULL)
Arguments
plotThe ggplot2 object
gtGtable object (optional)
Returns
List of selectors for each boxplot Determine if the boxplot is horizontal or vertical
Method determine_orientation()
Usage
Ggplot2BoxplotLayerProcessor$determine_orientation(plot)
Arguments
plotThe ggplot2 object
Returns
"horz" or "vert" Map numeric category codes to actual category names Uses panel_params axis labels from ggplot_build to map codes to labels
Method map_categories_to_names()
Usage
Ggplot2BoxplotLayerProcessor$map_categories_to_names(boxplot_data, plot)
Arguments
boxplot_dataList of boxplot statistics
plotThe ggplot2 object
Returns
Updated boxplot data with proper category names Find the main panel grob
Method find_panel_grob()
Usage
Ggplot2BoxplotLayerProcessor$find_panel_grob(gt)
Arguments
gtThe gtable to search
Returns
The panel grob or NULL Find children by type pattern
Method find_children_by_type()
Usage
Ggplot2BoxplotLayerProcessor$find_children_by_type(grob, type_pattern)
Arguments
grobThe grob to search
type_patternPattern to match
Returns
List of matching children Find the outlier container within a boxplot
Method find_outlier_container()
Usage
Ggplot2BoxplotLayerProcessor$find_outlier_container(gt, boxplot_id)
Arguments
gtThe gtable object
boxplot_idThe boxplot container ID
Returns
The outlier container ID or NULL Find the box container within a boxplot
Method find_box_container()
Usage
Ggplot2BoxplotLayerProcessor$find_box_container(gt, boxplot_id)
Arguments
gtThe gtable object
boxplot_idThe boxplot container ID
Returns
The box container ID or NULL Find the whisker container within a boxplot
Method find_whisker_container()
Usage
Ggplot2BoxplotLayerProcessor$find_whisker_container(gt, boxplot_id)
Arguments
gtThe gtable object
boxplot_idThe boxplot container ID
Returns
The whisker container ID or NULL Find the median container within a boxplot
Method find_median_container()
Usage
Ggplot2BoxplotLayerProcessor$find_median_container(gt, boxplot_id)
Arguments
gtThe gtable object
boxplot_idThe boxplot container ID
Returns
The median container ID or NULL Find a child element by pattern within a container
Method find_child_by_pattern()
Usage
Ggplot2BoxplotLayerProcessor$find_child_by_pattern(gt, container_id, pattern)
Arguments
gtThe gtable object
container_idThe container ID to search within
patternPattern to match
Returns
The matching child ID or NULL
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2BoxplotLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Dodged Bar Layer Processor
Description
Processes dodged bar plot layers with complete logic included
Super class
maidr::LayerProcessor -> Ggplot2DodgedBarLayerProcessor
Methods
Public methods
Inherited methods
Method process()
Usage
Ggplot2DodgedBarLayerProcessor$process(plot, layout, built = NULL, gt = NULL)
Method needs_reordering()
Usage
Ggplot2DodgedBarLayerProcessor$needs_reordering()
Method reorder_layer_data()
Usage
Ggplot2DodgedBarLayerProcessor$reorder_layer_data(data, plot)
Method extract_data()
Usage
Ggplot2DodgedBarLayerProcessor$extract_data(plot, built = NULL)
Method generate_selectors()
Usage
Ggplot2DodgedBarLayerProcessor$generate_selectors(plot, gt = NULL)
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2DodgedBarLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Heatmap Layer Processor
Description
Processes heatmap layers (geom_tile) with generic data and grob reordering
Super class
maidr::LayerProcessor -> Ggplot2HeatmapLayerProcessor
Methods
Public methods
Inherited methods
Method process()
Usage
Ggplot2HeatmapLayerProcessor$process(plot, layout, built = NULL, gt = NULL)
Method needs_reordering()
Usage
Ggplot2HeatmapLayerProcessor$needs_reordering()
Method reorder_layer_data()
Usage
Ggplot2HeatmapLayerProcessor$reorder_layer_data(data, plot)
Method extract_data()
Usage
Ggplot2HeatmapLayerProcessor$extract_data(plot, built = NULL)
Method generate_selectors()
Usage
Ggplot2HeatmapLayerProcessor$generate_selectors(plot, gt = NULL)
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2HeatmapLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Histogram Layer Processor
Description
Processes histogram plot layers with complete logic included
Super class
maidr::LayerProcessor -> Ggplot2HistogramLayerProcessor
Methods
Public methods
Inherited methods
maidr::LayerProcessor$apply_scale_mapping()maidr::LayerProcessor$extract_layer_axes()maidr::LayerProcessor$get_last_result()maidr::LayerProcessor$get_layer_index()maidr::LayerProcessor$initialize()maidr::LayerProcessor$needs_reordering()maidr::LayerProcessor$reorder_layer_data()maidr::LayerProcessor$set_last_result()
Method process()
Usage
Ggplot2HistogramLayerProcessor$process(plot, layout, built = NULL, gt = NULL)
Method extract_data()
Usage
Ggplot2HistogramLayerProcessor$extract_data(plot, built = NULL)
Method generate_selectors()
Usage
Ggplot2HistogramLayerProcessor$generate_selectors(plot, gt = NULL)
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2HistogramLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Final Line Layer Processor - Uses Actual SVG Structure
Description
Processes line plot layers using the actual gridSVG structure discovered: - Lines: GRID.polyline.61.1.1, GRID.polyline.61.1.2, GRID.polyline.61.1.3 - Points: geom_point.points.63.1.1 through geom_point.points.63.1.24 (grouped by series)
Super class
maidr::LayerProcessor -> Ggplot2LineLayerProcessor
Public fields
layer_infoInformation about the layer being processed
last_resultThe last processing result
Active bindings
layer_infoInformation about the layer being processed
last_resultThe last processing result
Methods
Public methods
Inherited methods
Method process()
Usage
Ggplot2LineLayerProcessor$process( plot, layout, built = NULL, gt = NULL, scale_mapping = NULL, grob_id = NULL, panel_id = NULL, panel_ctx = NULL )
Arguments
plotThe ggplot2 object
layoutLayout information
builtBuilt plot data (optional)
gtGtable object (optional)
scale_mappingScale mapping for faceted plots (optional)
grob_idGrob ID for faceted plots (optional)
panel_idPanel ID for faceted plots (optional)
Returns
List with data and selectors Extract data from line layer (single or multiline)
Method extract_data()
Usage
Ggplot2LineLayerProcessor$extract_data( plot, built = NULL, scale_mapping = NULL, panel_id = NULL )
Arguments
plotThe ggplot2 object
builtBuilt plot data (optional)
scale_mappingScale mapping for faceted plots (optional)
panel_idPanel ID for faceted plots (optional)
Returns
List of arrays, each containing series data points Extract data for multiple line series
Method extract_multiline_data()
Usage
Ggplot2LineLayerProcessor$extract_multiline_data(layer_data, plot)
Arguments
layer_dataThe built layer data
plotThe original ggplot2 object
Returns
List of arrays, each containing series data Extract data for single line (backward compatibility)
Method extract_single_line_data()
Usage
Ggplot2LineLayerProcessor$extract_single_line_data(layer_data)
Arguments
layer_dataThe built layer data
Returns
List containing single series data Get the grouping column name from plot mappings
Method get_group_column()
Usage
Ggplot2LineLayerProcessor$get_group_column(plot)
Arguments
plotThe ggplot2 object
Returns
Name of the grouping column Generate selectors using actual SVG structure
Method generate_selectors()
Usage
Ggplot2LineLayerProcessor$generate_selectors( plot, gt = NULL, grob_id = NULL, panel_ctx = NULL )
Arguments
plotThe ggplot2 object
gtGtable object (optional)
grob_idGrob ID for faceted plots (optional)
Returns
List of selectors for each series Generate selectors for multiline plots using actual structure
Method generate_multiline_selectors()
Usage
Ggplot2LineLayerProcessor$generate_multiline_selectors(base_id, num_series)
Arguments
base_idThe base ID from the grob (e.g., "61")
num_seriesNumber of series
Returns
List of selectors Generate selector for single line plot
Method generate_single_line_selector()
Usage
Ggplot2LineLayerProcessor$generate_single_line_selector(base_id)
Arguments
base_idThe base ID from the grob
Returns
List with single selector Find the main polyline grob (GRID.polyline.XX)
Method find_main_polyline_grob()
Usage
Ggplot2LineLayerProcessor$find_main_polyline_grob(gt)
Arguments
gtThe gtable to search
Returns
The main polyline grob or NULL Check if layer needs reordering
Method needs_reordering()
Usage
Ggplot2LineLayerProcessor$needs_reordering()
Returns
FALSE (line plots typically don't need reordering)
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2LineLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Plot Orchestrator Class
Description
Plot Orchestrator Class
Plot Orchestrator Class
Details
This class orchestrates the detection and processing of multiple layers in a ggplot2 object. It analyzes each layer individually and combines the results into a comprehensive interactive plot.
Public fields
plotThe ggplot2 object being processed
layersList of detected layer information
layer_processorsList of layer-specific processors
combined_dataCombined data from all layers
combined_selectorsCombined selectors from all layers
layoutLayout information from the plot
Active bindings
plotThe ggplot2 object being processed
layersList of detected layer information
layer_processorsList of layer-specific processors
combined_dataCombined data from all layers
combined_selectorsCombined selectors from all layers
layoutLayout information from the plot
Methods
Public methods
Method new()
Usage
Ggplot2PlotOrchestrator$new(plot)
Method detect_layers()
Usage
Ggplot2PlotOrchestrator$detect_layers()
Method analyze_single_layer()
Usage
Ggplot2PlotOrchestrator$analyze_single_layer(layer, layer_index)
Method determine_layer_type()
Usage
Ggplot2PlotOrchestrator$determine_layer_type(plot, layer_index)
Method create_layer_processors()
Usage
Ggplot2PlotOrchestrator$create_layer_processors()
Method create_layer_processor()
Usage
Ggplot2PlotOrchestrator$create_layer_processor(layer_info)
Method create_unified_layer_processor()
Usage
Ggplot2PlotOrchestrator$create_unified_layer_processor(layer_info)
Arguments
layer_infoLayer information
Returns
Layer processor instance
Method process_layers()
Usage
Ggplot2PlotOrchestrator$process_layers()
Method extract_layout()
Usage
Ggplot2PlotOrchestrator$extract_layout()
Method combine_layer_results()
Usage
Ggplot2PlotOrchestrator$combine_layer_results(layer_results)
Method generate_maidr_data()
Usage
Ggplot2PlotOrchestrator$generate_maidr_data()
Method get_gtable()
Usage
Ggplot2PlotOrchestrator$get_gtable()
Method get_layout()
Usage
Ggplot2PlotOrchestrator$get_layout()
Method get_combined_data()
Usage
Ggplot2PlotOrchestrator$get_combined_data()
Method get_layer_processors()
Usage
Ggplot2PlotOrchestrator$get_layer_processors()
Method get_layers()
Usage
Ggplot2PlotOrchestrator$get_layers()
Method is_patchwork_plot()
Check if the plot is a patchwork composition
Usage
Ggplot2PlotOrchestrator$is_patchwork_plot()
Returns
Logical indicating if the plot is a patchwork plot
Method is_faceted_plot()
Check if the plot is faceted
Usage
Ggplot2PlotOrchestrator$is_faceted_plot()
Returns
Logical indicating if the plot is faceted
Method process_faceted_plot()
Process a faceted plot using utility functions
Usage
Ggplot2PlotOrchestrator$process_faceted_plot()
Returns
NULL (sets internal state)
Method process_patchwork_plot()
Process a patchwork multipanel plot using utility functions
Usage
Ggplot2PlotOrchestrator$process_patchwork_plot()
Returns
NULL (sets internal state)
Method has_unsupported_layers()
Check if any layers are unsupported (unknown type)
Usage
Ggplot2PlotOrchestrator$has_unsupported_layers()
Returns
Logical indicating if there are unsupported layers
Method should_fallback()
Determine if the plot should fall back to image rendering
Usage
Ggplot2PlotOrchestrator$should_fallback()
Returns
Logical indicating if fallback should be used
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2PlotOrchestrator$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Point Layer Processor
Description
Processes scatter plot layers (geom_point) to extract point data and generate selectors for individual points in the SVG structure.
Super class
maidr::LayerProcessor -> Ggplot2PointLayerProcessor
Methods
Public methods
Inherited methods
maidr::LayerProcessor$apply_scale_mapping()maidr::LayerProcessor$extract_layer_axes()maidr::LayerProcessor$get_last_result()maidr::LayerProcessor$get_layer_index()maidr::LayerProcessor$initialize()maidr::LayerProcessor$needs_reordering()maidr::LayerProcessor$reorder_layer_data()maidr::LayerProcessor$set_last_result()
Method process()
Usage
Ggplot2PointLayerProcessor$process( plot, layout, built = NULL, gt = NULL, scale_mapping = NULL, grob_id = NULL, panel_id = NULL, panel_ctx = NULL )
Arguments
plotThe ggplot2 object
layoutLayout information
builtBuilt plot data (optional)
gtGtable object (optional)
scale_mappingScale mapping for faceted plots (optional)
grob_idGrob ID for faceted plots (optional)
panel_idPanel ID for faceted plots (optional)
Returns
List with data and selectors Extract axis labels from the plot
Method extract_axes_labels()
Usage
Ggplot2PointLayerProcessor$extract_axes_labels(plot, built = NULL)
Arguments
plotThe ggplot2 object
builtBuilt plot data (optional)
Returns
List with x and y axis labels Extract data from point layer
Method extract_data()
Usage
Ggplot2PointLayerProcessor$extract_data( plot, built = NULL, scale_mapping = NULL, panel_id = NULL )
Arguments
plotThe ggplot2 object
builtBuilt plot data (optional)
scale_mappingScale mapping for faceted plots (optional)
panel_idPanel ID for faceted plots (optional)
Returns
List with points array and color information Generate selectors for point elements
Method generate_selectors()
Usage
Ggplot2PointLayerProcessor$generate_selectors( plot, gt = NULL, grob_id = NULL, panel_ctx = NULL )
Arguments
plotThe ggplot2 object
gtGtable object (optional)
grob_idGrob ID for faceted plots (optional)
Returns
List of selectors Find the main panel grob
Method find_panel_grob()
Usage
Ggplot2PointLayerProcessor$find_panel_grob(gt)
Arguments
gtThe gtable to search
Returns
The panel grob or NULL Find children by type pattern
Method find_children_by_type()
Usage
Ggplot2PointLayerProcessor$find_children_by_type(grob, type_pattern)
Arguments
grobThe grob to search
type_patternPattern to match
Returns
List of matching children
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2PointLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
ggplot2 Processor Factory
Description
Factory for creating ggplot2-specific processors. This factory uses the existing ggplot2 layer processors and wraps them in the new unified interface.
Format
An R6 class inheriting from ProcessorFactory
Super class
maidr::ProcessorFactory -> Ggplot2ProcessorFactory
Methods
Public methods
Inherited methods
Method new()
Usage
Ggplot2ProcessorFactory$new()
Method create_processor()
Usage
Ggplot2ProcessorFactory$create_processor(plot_type, layer_info)
Arguments
plot_typeThe type of plot (e.g., "bar", "line", "point")
layer_infoInformation about the layer (contains plot object and metadata)
Returns
Processor instance for the specified plot type Get list of supported plot types
Method get_supported_types()
Usage
Ggplot2ProcessorFactory$get_supported_types()
Returns
Character vector of supported plot types Get the system name
Method get_system_name()
Usage
Ggplot2ProcessorFactory$get_system_name()
Returns
System name string Check if a specific processor class is available
Method is_processor_available()
Usage
Ggplot2ProcessorFactory$is_processor_available(processor_class_name)
Arguments
processor_class_nameName of the processor class
Returns
TRUE if available, FALSE otherwise Get available processor classes
Method get_available_processors()
Usage
Ggplot2ProcessorFactory$get_available_processors()
Returns
Character vector of available processor class names Create a processor with error handling
Method try_create_processor()
Usage
Ggplot2ProcessorFactory$try_create_processor(plot_type, plot_object)
Arguments
plot_typeThe type of plot
plot_objectThe plot object
Returns
Processor instance or NULL if creation fails
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2ProcessorFactory$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Smooth Layer Processor
Description
Processes smooth plot layers with complete logic included
Super class
maidr::LayerProcessor -> Ggplot2SmoothLayerProcessor
Methods
Public methods
Inherited methods
maidr::LayerProcessor$apply_scale_mapping()maidr::LayerProcessor$extract_layer_axes()maidr::LayerProcessor$get_last_result()maidr::LayerProcessor$get_layer_index()maidr::LayerProcessor$initialize()maidr::LayerProcessor$needs_reordering()maidr::LayerProcessor$reorder_layer_data()maidr::LayerProcessor$set_last_result()
Method process()
Usage
Ggplot2SmoothLayerProcessor$process(plot, layout, built = NULL, gt = NULL)
Method extract_data()
Usage
Ggplot2SmoothLayerProcessor$extract_data(plot, built = NULL)
Method generate_selectors()
Usage
Ggplot2SmoothLayerProcessor$generate_selectors(plot, gt = NULL)
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2SmoothLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Stacked Bar Layer Processor
Description
Processes stacked bar plot layers with complete logic included
Super class
maidr::LayerProcessor -> Ggplot2StackedBarProcessor
Methods
Public methods
Inherited methods
Method process()
Usage
Ggplot2StackedBarProcessor$process(plot, layout, built = NULL, gt = NULL)
Method needs_reordering()
Usage
Ggplot2StackedBarProcessor$needs_reordering()
Method reorder_layer_data()
Usage
Ggplot2StackedBarProcessor$reorder_layer_data(data, plot)
Method extract_plot_columns()
Usage
Ggplot2StackedBarProcessor$extract_plot_columns(plot)
Method extract_data()
Usage
Ggplot2StackedBarProcessor$extract_data(plot, built = NULL)
Method generate_selectors()
Usage
Ggplot2StackedBarProcessor$generate_selectors(plot, gt = NULL)
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2StackedBarProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Unknown Layer Processor
Description
Handles unsupported layer types gracefully by returning empty data
Super class
maidr::LayerProcessor -> Ggplot2UnknownLayerProcessor
Methods
Public methods
Inherited methods
maidr::LayerProcessor$apply_scale_mapping()maidr::LayerProcessor$extract_layer_axes()maidr::LayerProcessor$get_last_result()maidr::LayerProcessor$get_layer_index()maidr::LayerProcessor$initialize()maidr::LayerProcessor$needs_reordering()maidr::LayerProcessor$reorder_layer_data()maidr::LayerProcessor$set_last_result()
Method process()
Usage
Ggplot2UnknownLayerProcessor$process( plot, layout, built = NULL, gt = NULL, scale_mapping = NULL, grob_id = NULL, panel_ctx = NULL )
Method extract_data()
Usage
Ggplot2UnknownLayerProcessor$extract_data( plot, built = NULL, scale_mapping = NULL )
Method generate_selectors()
Usage
Ggplot2UnknownLayerProcessor$generate_selectors( plot, gt = NULL, grob_id = NULL, panel_ctx = NULL )
Method clone()
The objects of this class are cloneable with this method.
Usage
Ggplot2UnknownLayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Abstract Layer Processor Interface
Description
Abstract Layer Processor Interface
Abstract Layer Processor Interface
Details
This is the abstract base class for all layer processors. It defines the interface that all layer processors must implement.
Public fields
layer_infoInformation about the layer
layer_infoInformation about the layer
Methods
Public methods
Method new()
Initialize the layer processor
Usage
LayerProcessor$new(layer_info)
Arguments
layer_infoInformation about the layer
Method process()
Process the layer (MUST be implemented by subclasses)
Usage
LayerProcessor$process( plot, layout, built = NULL, gt = NULL, scale_mapping = NULL, grob_id = NULL, panel_ctx = NULL )
Arguments
plotThe ggplot2 object
layoutLayout information
builtBuilt plot data (optional)
gtGtable object (optional)
scale_mappingScale mapping for faceted plots (optional)
grob_idGrob ID for faceted plots (optional)
panel_ctxPanel context for panel-scoped selector generation (optional)
Returns
List with data and selectors
Method extract_data()
Extract data from the layer (MUST be implemented by subclasses)
Usage
LayerProcessor$extract_data(plot, built = NULL, scale_mapping = NULL)
Arguments
plotThe ggplot2 object
builtBuilt plot data (optional)
scale_mappingScale mapping for faceted plots (optional)
Returns
Extracted data
Method generate_selectors()
Generate selectors for the layer (MUST be implemented by subclasses)
Usage
LayerProcessor$generate_selectors( plot, gt = NULL, grob_id = NULL, panel_ctx = NULL )
Arguments
plotThe ggplot2 object
gtGtable object (optional)
grob_idGrob ID for faceted plots (optional)
panel_ctxPanel context for panel-scoped selector generation (optional)
Returns
List of selectors
Method needs_reordering()
Check if this layer needs reordering (OPTIONAL - default: FALSE)
Usage
LayerProcessor$needs_reordering()
Returns
Logical indicating if reordering is needed
Method reorder_layer_data()
Reorder layer data (OPTIONAL - default: no-op)
Usage
LayerProcessor$reorder_layer_data(data, plot)
Arguments
datadata.frame effective for this layer
plotfull ggplot object (for mappings)
Returns
Reordered data
Method get_layer_index()
Get layer index
Usage
LayerProcessor$get_layer_index()
Returns
Layer index
Method set_last_result()
Store the last processed result (used by orchestrator)
Usage
LayerProcessor$set_last_result(result)
Arguments
resultThe result to store
Method get_last_result()
Get the last processed result
Usage
LayerProcessor$get_last_result()
Returns
The last result
Method extract_layer_axes()
Extract axes labels for this specific layer
Usage
LayerProcessor$extract_layer_axes(plot, layout)
Arguments
plotThe ggplot object
layoutGlobal layout with fallback axes
Returns
List with x and y axis labels
Method apply_scale_mapping()
Apply scale mapping to numeric values
Usage
LayerProcessor$apply_scale_mapping(numeric_values, scale_mapping)
Arguments
numeric_valuesVector of numeric values
scale_mappingScale mapping vector
Returns
Mapped values
Method clone()
The objects of this class are cloneable with this method.
Usage
LayerProcessor$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
MAIDR JavaScript library version bundled with this package
Description
MAIDR JavaScript library version bundled with this package
Usage
MAIDR_VERSION
Format
An object of class character of length 1.
Plot System Registry
Description
Central registry for managing different plotting systems and their adapters. This registry allows dynamic registration and discovery of plotting systems and their associated adapters and processor factories.
Format
An R6 class
Methods
Public methods
Method register_system()
Usage
PlotSystemRegistry$register_system(system_name, adapter, processor_factory)
Arguments
system_nameName of the plotting system (e.g., "ggplot2", "base_r")
adapterAdapter instance for this system
processor_factoryProcessor factory instance for this system Detect which system can handle a plot object
Method detect_system()
Usage
PlotSystemRegistry$detect_system(plot_object)
Arguments
plot_objectThe plot object to check
Returns
System name if found, NULL otherwise Get the adapter for a specific system
Method get_adapter()
Usage
PlotSystemRegistry$get_adapter(system_name)
Arguments
system_nameName of the system
Returns
Adapter instance Get the processor factory for a specific system
Method get_processor_factory()
Usage
PlotSystemRegistry$get_processor_factory(system_name)
Arguments
system_nameName of the system
Returns
Processor factory instance Get the adapter for a plot object (auto-detect system)
Method get_adapter_for_plot()
Usage
PlotSystemRegistry$get_adapter_for_plot(plot_object)
Arguments
plot_objectThe plot object
Returns
Adapter instance Get the processor factory for a plot object (auto-detect system)
Method get_processor_factory_for_plot()
Usage
PlotSystemRegistry$get_processor_factory_for_plot(plot_object)
Arguments
plot_objectThe plot object
Returns
Processor factory instance List all registered systems
Method list_systems()
Usage
PlotSystemRegistry$list_systems()
Returns
Character vector of registered system names Check if a system is registered
Method is_system_registered()
Usage
PlotSystemRegistry$is_system_registered(system_name)
Arguments
system_nameName of the system
Returns
TRUE if registered, FALSE otherwise Unregister a system
Method unregister_system()
Usage
PlotSystemRegistry$unregister_system(system_name)
Arguments
system_nameName of the system to unregister
Method clone()
The objects of this class are cloneable with this method.
Usage
PlotSystemRegistry$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Processor Factory Base Class
Description
Abstract base class for creating processors specific to different plotting systems. Each plotting system should have its own factory implementation that creates the appropriate processors for different plot types.
Format
An R6 class
Methods
Public methods
Method create_processor()
Usage
ProcessorFactory$create_processor(plot_type, plot_object)
Arguments
plot_typeThe type of plot (e.g., "bar", "line", "point")
plot_objectThe plot object to process
Returns
Processor instance for the specified plot type Abstract method to get list of supported plot types
Method get_supported_types()
Usage
ProcessorFactory$get_supported_types()
Returns
Character vector of supported plot types Check if a plot type is supported by this factory
Method supports_plot_type()
Usage
ProcessorFactory$supports_plot_type(plot_type)
Arguments
plot_typeThe plot type to check
Returns
TRUE if supported, FALSE otherwise Get system name (should be overridden by subclasses)
Method get_system_name()
Usage
ProcessorFactory$get_system_name()
Returns
System name string
Method clone()
The objects of this class are cloneable with this method.
Usage
ProcessorFactory$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
System Adapter Base Class
Description
System Adapter Base Class
System Adapter Base Class
Format
An R6 class
Details
Abstract base class for adapting different plotting systems to the unified maidr interface. Each plotting system (ggplot2, base R, lattice, etc.) should have its own adapter implementation.
Public fields
system_nameName of the plotting system
Methods
Public methods
Method new()
Initialize the adapter
Usage
SystemAdapter$new(system_name)
Arguments
system_nameName of the plotting system Abstract method to check if this adapter can handle a plot object
Method can_handle()
Usage
SystemAdapter$can_handle(plot_object)
Arguments
plot_objectThe plot object to check
Returns
TRUE if this adapter can handle the object, FALSE otherwise Abstract method to create an orchestrator for this system
Method create_orchestrator()
Usage
SystemAdapter$create_orchestrator(plot_object)
Arguments
plot_objectThe plot object to process
Returns
Orchestrator instance specific to this system
Method clone()
The objects of this class are cloneable with this method.
Usage
SystemAdapter$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Convert Accuracy to Decimal Places
Description
Converts the scales package accuracy parameter to a decimal count.
For example, accuracy = 0.01 becomes decimals = 2.
Usage
accuracy_to_decimals(accuracy)
Arguments
accuracy |
The accuracy value (e.g., 0.01 for 2 decimal places) |
Value
Integer number of decimal places
Add maidr-data to SVG using proper XML manipulation
Description
Add maidr-data to SVG using proper XML manipulation
Usage
add_maidr_data_to_svg(svg_content, maidr_data)
Arguments
svg_content |
Character vector of SVG lines |
maidr_data |
The maidr-data structure |
Value
Modified SVG content
Apply modular patches to barplot arguments
Description
Apply modular patches to barplot arguments
Usage
apply_barplot_patches(args)
Arguments
args |
List of arguments passed to barplot |
Value
Modified arguments with applied patches
Apply sorting logic to barplot arguments for consistent visual ordering
Description
Apply sorting logic to barplot arguments for consistent visual ordering
Usage
apply_barplot_sorting(args)
Arguments
args |
List of arguments passed to barplot |
Value
Modified arguments with sorted matrix data
Apply scale mapping to convert numeric positions to category labels
Description
In faceted plots, ggplot2 converts categorical x-values to numeric positions (1, 2, 3, ...) for efficiency. This function converts them back to the original category labels using the scale mapping.
Usage
apply_scale_mapping(numeric_values, scale_mapping)
Arguments
numeric_values |
Vector of numeric x positions from built plot data |
scale_mapping |
Named vector mapping positions to labels (e.g., c("1" = "A", "2" = "B")) |
Value
Vector of category labels
Build Format Config from Detected Type and Parameters
Description
Build Format Config from Detected Type and Parameters
Usage
build_format_config(format_type, prefix, suffix, accuracy, digits)
Arguments
format_type |
Detected format type |
prefix |
Prefix from closure |
suffix |
Suffix from closure |
accuracy |
Accuracy from closure |
digits |
Digits from closure |
Value
Format configuration list
Classify a Base R Function
Description
Determines the classification level of a Base R plotting function.
Usage
classify_function(function_name)
Arguments
function_name |
Name of the function to classify |
Value
Character string: "HIGH", "LOW", "LAYOUT", or "UNKNOWN"
Clean MAIDR internal arguments from args list
Description
Removes internal arguments (starting with .maidr_) from an args list before passing to original functions during replay.
Usage
clean_maidr_args(args)
Arguments
args |
List of arguments |
Value
Cleaned args list without .maidr_* entries
Clear All Device Storage
Description
Clears storage for all devices.
Usage
clear_all_device_storage()
Value
NULL (invisible)
Clear Device Storage
Description
Clears all stored plot calls for a specific device.
Usage
clear_device_storage(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
NULL (invisible)
Clear recorded plot calls
Description
Clear recorded plot calls
Usage
clear_plot_calls(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID (defaults to current device) |
Value
NULL (invisible)
Close and clean up the MAIDR temp device
Description
Close and clean up the MAIDR temp device
Usage
close_maidr_temp_device()
Value
NULL (invisible)
Combine data from multiple layers in facet processing
Description
Combine data from multiple layers in facet processing
Usage
combine_facet_layer_data(layer_results)
Arguments
layer_results |
List of layer processing results |
Value
Combined data
Combine selectors from multiple layers in facet processing
Description
Combine selectors from multiple layers in facet processing
Usage
combine_facet_layer_selectors(layer_results)
Arguments
layer_results |
List of layer processing results |
Value
Combined selectors
Create enhanced wrapper for axis to capture scales:: format config
Description
This wrapper intercepts axis() calls and checks if the labels argument is a scales:: label function (closure). If so, it extracts the format configuration before applying the function to get the actual labels.
Usage
create_axis_wrapper(original_function)
Arguments
original_function |
Original axis function |
Value
Enhanced wrapped function
Create enhanced wrapper for barplot with sorting logic
Description
Create enhanced wrapper for barplot with sorting logic
Usage
create_barplot_wrapper(original_function)
Arguments
original_function |
Original barplot function |
Value
Enhanced wrapped function
Create enhanced SVG with maidr data
Description
Create enhanced SVG with maidr data
Usage
create_enhanced_svg(gt, maidr_data, ...)
Arguments
gt |
A gtable object |
maidr_data |
The maidr-data structure |
... |
Additional arguments |
Value
Character vector of SVG content
Create Fallback HTML Content
Description
Creates HTML content with the fallback image, styled to fit in iframes.
Usage
create_fallback_html(
plot = NULL,
shiny = FALSE,
format = "png",
width = 7,
height = 5
)
Arguments
plot |
A ggplot2 object or NULL for Base R plots |
shiny |
If TRUE, returns just the image tag for Shiny/knitr use |
format |
Image format (default: "png") |
width |
Image width in inches |
height |
Image height in inches |
Value
HTML content string or htmltools object
Create iframe HTML tag for fallback static image
Description
Creates an iframe element with base64-encoded src containing a static image. Used when plots contain unsupported layers and fall back to PNG rendering. Unlike create_maidr_iframe, this does not include MAIDR.js dependencies.
Usage
create_fallback_iframe(
html_content,
width = "100%",
height = "450px",
plot_id = NULL
)
Arguments
html_content |
Character string of HTML content (with img tag) |
width |
Width of the iframe (default: "100%") |
height |
Height of the iframe (default: "450px") |
plot_id |
Unique identifier for the plot |
Value
Character string of iframe HTML
Create Fallback Image for Unsupported Plots
Description
Renders a plot as a standard PNG image when MAIDR cannot process it. This is used as a fallback for unsupported plot types or layers.
Usage
create_fallback_image(
plot = NULL,
format = "png",
width = 7,
height = 5,
res = 150
)
Arguments
plot |
A ggplot2 object or NULL for Base R plots |
format |
Image format: "png" (default), "svg", or "jpeg" |
width |
Image width in inches (default: 7) |
height |
Image height in inches (default: 5) |
res |
Resolution in DPI for PNG/JPEG (default: 150) |
Value
Base64-encoded image data URI string
Create a function wrapper
Description
Create a function wrapper
Usage
create_function_wrapper(function_name, original_function)
Arguments
function_name |
Name of the function |
original_function |
Original function to wrap |
Value
Wrapped function
Create HTML document with dependencies
Description
Create HTML document with dependencies
Usage
create_html_document(svg_content)
Arguments
svg_content |
Character vector of SVG content |
Value
An htmltools HTML document object
Create inline image HTML for non-iframe rendering
Description
Creates a simple img tag for fallback/non-HTML output. Used when we don't need iframe isolation (unsupported plots in HTML, or any plot in PDF/EPUB output).
Usage
create_inline_image(plot = NULL, width = "100%", height = "auto")
Arguments
plot |
A ggplot object or NULL for Base R |
width |
Width for the image container |
height |
Height for the image container |
Value
Character string of HTML with img tag
Create HTML document with maidr enhancements using the orchestrator
Description
Create HTML document with maidr enhancements using the orchestrator
Usage
create_maidr_html(plot, shiny = FALSE, orchestrator = NULL, ...)
Arguments
plot |
A ggplot2 object |
shiny |
If TRUE, returns just the SVG content instead of full HTML document |
orchestrator |
Optional pre-created orchestrator to reuse (avoids double creation) |
... |
Additional arguments passed to internal functions |
Value
An htmltools HTML document object or SVG content
Create iframe HTML tag for isolated MAIDR plot
Description
Creates an iframe element with base64-encoded src containing the complete MAIDR plot. Uses data URI with base64 encoding to avoid quote escaping issues with JSON. This isolates each plot in its own document/JavaScript context.
Usage
create_maidr_iframe(
svg_content,
width = "100%",
height = "450px",
plot_id = NULL
)
Arguments
svg_content |
Character vector of SVG content with maidr-data attribute |
width |
Width of the iframe (default: "100%") |
height |
Height of the iframe (default: "450px") |
plot_id |
Unique identifier for the plot |
Value
Character string of iframe HTML
Create MAIDR Widget for knitr (Internal)
Description
Internal function to create a MAIDR widget from either ggplot or Base R plots.
Usage
create_maidr_widget_internal(plot = NULL)
Arguments
plot |
A ggplot object or NULL for Base R |
Value
An htmlwidget object
Create self-contained HTML for iframe embedding
Description
Generates a complete standalone HTML document with MAIDR.js that can be embedded in an iframe for isolation. Each iframe gets its own JavaScript context, avoiding MAIDR.js singleton pattern issues with multiple plots. Auto-detects internet availability: uses CDN if online, inline local if offline.
Usage
create_standalone_html(svg_content)
Arguments
svg_content |
Character vector of SVG content with maidr-data attribute |
Value
Character string of complete HTML document
Detect Multi-panel Configuration
Description
Analyzes layout calls to determine multi-panel configuration.
Usage
detect_panel_configuration(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
Panel configuration list or NULL
Detect Format Type from scales Closure Parameters
Description
Detect Format Type from scales Closure Parameters
Usage
detect_scales_format_type(prefix, suffix, digits, scale, accuracy)
Arguments
prefix |
Prefix string from closure |
suffix |
Suffix string from closure |
digits |
Digits parameter (only in label_scientific) |
scale |
Scale parameter |
accuracy |
Accuracy parameter |
Value
Format type string or NULL
Display HTML document directly
Description
Display HTML document directly
Usage
display_html(html_doc)
Arguments
html_doc |
An htmltools HTML document object |
Display HTML file in browser
Description
Display HTML file in browser
Usage
display_html_file(file)
Arguments
file |
HTML file path |
Ensure a device is open before plotting (suppress default window)
Description
Ensure a device is open before plotting (suppress default window)
Usage
ensure_maidr_device()
Value
The current device ID after ensuring one is open
Extract Format Configuration for a Single Axis
Description
Extracts formatting configuration by inspecting the closure environment of scales label functions (e.g., scales::label_dollar, scales::label_percent).
Usage
extract_axis_format(built, axis = "x")
Arguments
built |
A built ggplot2 object |
axis |
Either "x" or "y" |
Value
Format configuration list or NULL
Extract Format Configuration from Built Plot
Description
Extracts MAIDR format configuration from the scale objects in a built
ggplot2 plot. This looks for the maidr_format attribute attached
by the maidr label functions.
Usage
extract_format_config(built)
Arguments
built |
A built ggplot2 object from |
Value
A list with x and/or y format configurations,
or NULL if no format config is found
Extract Format Configuration from scales Package Closure
Description
Inspects the closure environment of a scales label function to extract formatting parameters. This allows users to use scales:: functions directly without needing maidr:: wrappers.
Usage
extract_from_scales_closure(label_func)
Arguments
label_func |
A label function (e.g., from scales::label_dollar) |
Value
Format configuration list or NULL
Extract layout from a single leaf ggplot
Description
Extract layout from a single leaf ggplot
Usage
extract_leaf_plot_layout(leaf_plot)
Arguments
leaf_plot |
The ggplot object |
Value
Layout with title and axes
Recursively extract leaf ggplots in visual order
Description
Recursively extract leaf ggplots in visual order
Usage
extract_patchwork_leaves(node)
Arguments
node |
Patchwork node or ggplot object |
Value
List of leaf ggplot objects
Extract scale mapping from built plot
Description
Extracts the scale mapping from a built ggplot2 plot object. This mapping converts numeric positions back to category labels.
Usage
extract_scale_mapping(built)
Arguments
built |
Built plot data from ggplot2::ggplot_build() |
Value
Named vector for scale mapping, or NULL if no mapping available
Find children matching a type pattern
Description
Find children matching a type pattern
Usage
find_children_by_type(parent_grob, pattern)
Arguments
parent_grob |
The parent grob to search |
pattern |
The pattern to match in grob names |
Value
Vector of matching child names
Utility functions for robust selector generation in Base R plots
Description
These functions provide a robust way to find grob elements and generate CSS selectors, independent of panel structure or hardcoded values. Find grob by element type pattern
Usage
find_graphics_plot_grob(grob, element_type, plot_index = NULL)
Arguments
grob |
The grob tree to search (typically from ggplotify::as.grob()) |
element_type |
The element type to search for (e.g., "rect", "lines", "points") |
plot_index |
Optional plot index to match (for multipanel layouts) |
Details
Searches recursively through a grob tree to find a grob whose name matches the pattern: graphics-plot-<number>-<element_type>-<number>
Value
The name of the first matching grob, or NULL if not found
Find the original function in loaded namespaces
Description
Find the original function in loaded namespaces
Usage
find_original_function(function_name)
Arguments
function_name |
Name of the function to find |
Value
Original function or NULL if not found
Find the panel grob in a grob tree
Description
Find the panel grob in a grob tree
Usage
find_panel_grob(grob_tree)
Arguments
grob_tree |
The grob tree to search |
Value
The panel grob or NULL if not found
Discover panels via gtable layout rows named '^panel-<num>' or '^panel-<row>-<col>' Returns a data.frame with panel_index, name, t, l, row, col
Description
Discover panels via gtable layout rows named '^panel-<num>' or '^panel-<row>-<col>' Returns a data.frame with panel_index, name, t, l, row, col
Usage
find_patchwork_panels(gtable)
Arguments
gtable |
Gtable object |
Value
Data frame with panel information
Format Extraction Utilities
Description
Utility functions for extracting and converting axis format configuration from ggplot2 scale objects to MAIDR format specifications.
Generate robust CSS selector from grob name
Description
Creates a CSS selector that targets SVG elements by their ID pattern, without relying on panel structure or hardcoded values.
Usage
generate_robust_css_selector(grob_name, svg_element)
Arguments
grob_name |
The name of the grob (e.g., "graphics-plot-1-rect-1") |
svg_element |
The SVG element type to target (e.g., "rect", "polyline") |
Value
A robust CSS selector string, or NULL if grob_name is invalid
Generate robust selector for any element type
Description
Creates a robust CSS selector that works regardless of panel structure. This is the main function that layer processors should use.
Usage
generate_robust_selector(
grob,
element_type,
svg_element,
plot_index = NULL,
max_elements = NULL
)
Arguments
grob |
The grob tree to analyze |
element_type |
The element type to search for (e.g., "rect", "lines") |
svg_element |
The SVG element to target (e.g., "rect", "polyline") |
plot_index |
Optional plot index for multipanel layouts |
max_elements |
Optional limit on number of elements to target |
Value
A robust CSS selector string, or NULL if element not found
Generate a unique ID for MAIDR plots
Description
Creates a unique identifier combining timestamp and counter to ensure uniqueness even when multiple plots are created within the same second.
Usage
generate_unique_id()
Value
Character string with unique ID
Get Flat List of All Patchable Functions
Description
Returns a flat vector of all functions to patch.
Usage
get_all_function_names()
Value
Character vector of all patchable function names
Get All Patchable Functions
Description
Returns a list of all functions that should be patched, organized by class.
Usage
get_all_patchable_functions()
Value
List with HIGH, LOW, and LAYOUT function vectors
Get All Plot Groups
Description
Retrieves all plot groups for a device.
Usage
get_all_plot_groups(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
List of plot groups
Get Current Plot Index
Description
Returns the current active plot index for a device.
Usage
get_current_plot_index(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
Current plot index (integer)
Get Plot Calls from Device Storage
Description
Retrieves all plot calls for a specific device.
Usage
get_device_calls(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
List of plot call entries
Filter Device Calls by Classification
Description
Retrieves plot calls of a specific classification level.
Usage
get_device_calls_by_class(
device_id = grDevices::dev.cur(),
class_level = "HIGH"
)
Arguments
device_id |
Graphics device ID |
class_level |
Classification level: "HIGH", "LOW", "LAYOUT" |
Value
List of filtered plot call entries
Base R State Tracking
Description
This module tracks the plotting state for each graphics device, including active plot index, panel configuration, and plot grouping.
Usage
get_device_state(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
Device state list
Get or Initialize Device Storage
Description
Retrieves storage for a specific graphics device, creating it if needed.
Usage
get_device_storage(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID (from grDevices::dev.cur()) |
Value
Device storage list
Get Device Storage Summary
Description
Returns summary information about device storage (for debugging).
Usage
get_device_storage_summary()
Value
List with device storage statistics
Get facet group information for a panel
Description
Get facet group information for a panel
Usage
get_facet_groups(panel_info, built)
Arguments
panel_info |
Panel information from layout |
built |
Built plot data |
Value
List of facet group information
Get Fallback Image Format
Description
Get Fallback Image Format
Usage
get_fallback_format()
Value
Character string of the format to use
Get All Functions of a Specific Class
Description
Returns all function names for a given classification level.
Usage
get_functions_by_class(class_level)
Arguments
class_level |
Classification level: "HIGH", "LOW", or "LAYOUT" |
Value
Character vector of function names
Get the global plot system registry
Description
Get the global plot system registry
Usage
get_global_registry()
Value
PlotSystemRegistry instance
Get Group Count
Description
Returns the number of plot groups for a device.
Usage
get_group_count(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
Number of groups (integer)
Get HIGH-level Calls
Description
Get HIGH-level Calls
Usage
get_high_level_calls(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
List of HIGH-level plot calls
Get LAYOUT Calls
Description
Get LAYOUT Calls
Usage
get_layout_calls(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
List of LAYOUT-level plot calls
Get LOW-level Calls
Description
Get LOW-level Calls
Usage
get_low_level_calls(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
List of LOW-level plot calls
Get original (unwrapped) function by name
Description
Get original (unwrapped) function by name
Usage
get_original_function(function_name)
Arguments
function_name |
Name of the function |
Value
The original function
Get Panel Configuration
Description
Returns the panel configuration for a device.
Usage
get_panel_config(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
Panel configuration list
Get recorded plot calls
Description
Get recorded plot calls
Usage
get_plot_calls(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID (defaults to current device) |
Value
List of recorded plot calls
Get Plot Group by Index
Description
Retrieves a specific plot group.
Usage
get_plot_group(device_id = grDevices::dev.cur(), group_index)
Arguments
device_id |
Graphics device ID |
group_index |
Index of the group to retrieve |
Value
Plot group list or NULL if not found
Base R Plot Grouping
Description
This module groups plot calls into logical units: - Each HIGH-level call starts a new plot group - Subsequent LOW-level calls are associated with the current plot group - LAYOUT calls affect multi-panel configuration
Usage
group_device_calls(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
List of plot groups, each containing HIGH and LOW calls
Check if Device Has Calls
Description
Checks whether a specific device has any recorded plot calls.
Usage
has_device_calls(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
TRUE if device has calls, FALSE otherwise
Initialize Base R function patching
Description
This function sets up the function patching system by wrapping Base R plotting functions (HIGH, LOW, and LAYOUT levels). It should be called before any Base R plotting commands.
Usage
initialize_base_r_patching(include_low = TRUE, include_layout = TRUE)
Arguments
include_low |
Include LOW-level functions (lines, points, etc.) |
include_layout |
Include LAYOUT functions (par, layout, etc.) |
Details
Wrappers are installed once into the package namespace during .onLoad (when the namespace is still open). Subsequent calls just activate the patching flag; wrappers check this flag to decide whether to record calls or simply pass through to the original function.
Value
NULL (invisible)
Base R System Initialization
Description
Initialize and register the Base R system with the global registry. This function sets up the Base R adapter and processor factory.
Usage
initialize_base_r_system()
Value
NULL (invisible)
ggplot2 System Initialization
Description
Initialize and register the ggplot2 system with the global registry. This function sets up the ggplot2 adapter and processor factory.
Usage
initialize_ggplot2_system()
Value
NULL (invisible)
Check if Fallback is Enabled
Description
Check if Fallback is Enabled
Usage
is_fallback_enabled()
Value
Logical indicating if fallback rendering is enabled
Check if Fallback Warning is Enabled
Description
Check if Fallback Warning is Enabled
Usage
is_fallback_warning_enabled()
Value
Logical indicating if warnings should be shown
Check if Function is HIGH-level
Description
Check if Function is HIGH-level
Usage
is_high_level_function(function_name)
Arguments
function_name |
Name of the function |
Value
TRUE if HIGH-level, FALSE otherwise
Check if current knitr output format is HTML
Description
Detects whether the current RMarkdown document is being rendered to HTML format (html_document, bookdown, etc.) vs non-HTML formats (pdf, epub, etc.)
Usage
is_html_output()
Value
TRUE if rendering to HTML, FALSE otherwise
Check Internal Guard Flag
Description
Checks if we're currently in internal code (to prevent recursive tracing).
Usage
is_internal_call()
Value
TRUE if internal guard is set, FALSE otherwise
Check if Function is LAYOUT-level
Description
Check if Function is LAYOUT-level
Usage
is_layout_function(function_name)
Arguments
function_name |
Name of the function |
Value
TRUE if LAYOUT-level, FALSE otherwise
Check if Function is LOW-level
Description
Check if Function is LOW-level
Usage
is_low_level_function(function_name)
Arguments
function_name |
Name of the function |
Value
TRUE if LOW-level, FALSE otherwise
Check if MAIDR RMarkdown Mode is Enabled
Description
Check if MAIDR RMarkdown Mode is Enabled
Usage
is_maidr_on()
Value
Logical indicating if MAIDR mode is active
Check if the current device is the MAIDR temp device
Description
Check if the current device is the MAIDR temp device
Usage
is_maidr_temp_device()
Value
TRUE if current device is the temp device
Check if Multi-panel Layout is Active
Description
Check if Multi-panel Layout is Active
Usage
is_multipanel_active(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
TRUE if multi-panel layout is active, FALSE otherwise
Check if patching is active
Description
Check if patching is active
Usage
is_patching_active()
Value
TRUE if patching is active, FALSE otherwise
Check if Base R patching is currently active
Description
Wrappers are installed once during .onLoad and remain in the namespace. This flag controls whether they record calls or act as pass-through.
Usage
is_patching_enabled()
Value
TRUE if patching is active
Custom knit_print Method for density Objects
Description
Suppresses the default printing of density return values in RMarkdown. The density() function is not patched (it's in stats, not graphics), so we need this method to suppress its output.
Usage
knit_print.density(x, options = list(), ...)
Arguments
x |
A density object (from density()) |
options |
Chunk options from knitr |
... |
Additional arguments (ignored) |
Value
An invisible empty string
Custom knit_print Method for ggplot Objects
Description
Converts ggplot objects to MAIDR widgets for accessible rendering in RMarkdown. Uses iframe-based isolation to ensure each plot has its own MAIDR.js context. Automatically falls back to image rendering for unsupported plot types or non-HTML output formats (PDF, EPUB).
Usage
knit_print.ggplot(x, options = list(), ...)
Arguments
x |
A ggplot object |
options |
Chunk options from knitr |
... |
Additional arguments (ignored) |
Value
A knit_asis object containing the iframe HTML or inline image
Custom knit_print Method for histogram Objects
Description
Suppresses the default printing of histogram return values in RMarkdown. The plot is already rendered via the plot hook; this prevents the histogram object structure from being printed as text output.
Usage
knit_print.histogram(x, options = list(), ...)
Arguments
x |
A histogram object (from hist()) |
options |
Chunk options from knitr |
... |
Additional arguments (ignored) |
Value
An invisible empty string
Log Plot Call to Device Storage
Description
Records a plot call in the device-specific storage.
Usage
log_plot_call_to_device(
function_name,
call_expr,
args,
device_id = grDevices::dev.cur()
)
Arguments
function_name |
Name of the plotting function |
call_expr |
The call expression |
args |
List of function arguments |
device_id |
Graphics device ID |
Value
NULL (invisible)
Get the MAIDR CDN base URL
Description
Uses @latest to always fetch the most recent version from CDN.
Usage
maidr_cdn_url()
Value
CDN URL string
Get Current MAIDR Fallback Settings
Description
Retrieves the current fallback configuration for MAIDR.
Usage
maidr_get_fallback()
Value
A list with the current fallback settings:
-
enabled: Logical indicating if fallback is enabled -
format: Character string of the image format -
warning: Logical indicating if warnings are shown
See Also
[maidr_set_fallback()] to configure settings
Examples
# Get current settings
settings <- maidr_get_fallback()
print(settings)
Register JS/CSS dependencies for maidr with auto-detection
Description
Creates HTML dependencies for MAIDR JavaScript and CSS files. Automatically detects internet availability: - If internet is available: uses CDN (smaller HTML, better caching) - If offline: uses local bundled files (works without internet)
Usage
maidr_html_dependencies()
Value
A list containing one htmlDependency object
Get paths to local MAIDR assets
Description
Returns the file paths to the locally bundled MAIDR JavaScript and CSS files.
Usage
maidr_local_assets()
Value
A named list with 'js' and 'css' file paths
Disable MAIDR Rendering in RMarkdown
Description
Disables automatic MAIDR rendering and restores normal plot behavior.
Usage
maidr_off()
Value
Invisible TRUE on success
See Also
[maidr_on()] to enable MAIDR rendering
Enable MAIDR Rendering in RMarkdown
Description
Enables automatic accessible rendering of ggplot2 and Base R plots in RMarkdown documents. When enabled, plots are automatically converted to interactive MAIDR widgets with keyboard navigation and screen reader support.
Usage
maidr_on()
Value
Invisible TRUE on success
See Also
[maidr_off()] to disable MAIDR rendering
Examples
# In RMarkdown setup chunk:
library(maidr)
maidr_on()
# Now all plots render as accessible MAIDR widgets
library(ggplot2)
ggplot(mtcars, aes(x = factor(cyl))) +
geom_bar()
barplot(table(mtcars$cyl))
MAIDR Output Container for Shiny UI
Description
Creates a Shiny output container for MAIDR widgets using htmlwidgets. This provides automatic dependency injection and robust JavaScript initialization.
Usage
maidr_output(output_id, width = "100%", height = "400px")
Arguments
output_id |
The output variable to read the plot from |
width |
The width of the plot container (default: "100percent") |
height |
The height of the plot container (default: "400px") |
Value
A Shiny widget output function for use in UI
Examples
if (interactive()) {
library(shiny)
ui <- fluidPage(maidr_output("myplot"))
}
knitr Plot Hook for Base R Plots
Description
Intercepts Base R plot output and converts to MAIDR iframe. Uses iframe-based isolation to ensure each plot has its own MAIDR.js context. Automatically falls back to image rendering for unsupported plot types or non-HTML output formats (PDF, EPUB). This replaces knitr's default plot hook when maidr_on() is called.
Usage
maidr_plot_hook(x, options)
Arguments
x |
The plot file path from knitr |
options |
Chunk options |
Value
HTML string for the plot
Configure MAIDR Fallback Behavior
Description
Configure how MAIDR handles unsupported plot types or layers. When fallback is enabled, unsupported plots are rendered as static images instead of failing or returning empty data.
Usage
maidr_set_fallback(enabled = TRUE, format = "png", warning = TRUE)
Arguments
enabled |
Logical. If TRUE (default), unsupported plots fall back to image rendering. If FALSE, unsupported layers return empty data. |
format |
Character. Image format for fallback: "png" (default), "svg", or "jpeg". |
warning |
Logical. If TRUE (default), shows a warning message when falling back to image rendering. |
Value
Invisibly returns a list of the previous settings.
See Also
[maidr_get_fallback()] to retrieve current settings
Examples
# Save current settings and restore on exit
old_settings <- maidr_get_fallback()
on.exit(maidr_set_fallback(
enabled = old_settings$enabled,
format = old_settings$format,
warning = old_settings$warning
))
# Disable fallback (unsupported plots will have empty data)
maidr_set_fallback(enabled = FALSE)
# Use SVG format for fallback images
maidr_set_fallback(format = "svg")
# Disable warning messages
maidr_set_fallback(warning = FALSE)
# Configure multiple options
maidr_set_fallback(enabled = TRUE, format = "png", warning = TRUE)
Create MAIDR htmlwidget
Description
Internal function that creates an interactive MAIDR widget from a ggplot object. This is called internally by render_maidr() and should not be called directly. Use maidr_output() and render_maidr() for Shiny integration instead.
Usage
maidr_widget(plot, width = NULL, height = NULL, element_id = NULL, ...)
Arguments
plot |
A ggplot object to render as an interactive MAIDR widget |
width |
The width of the widget in pixels or CSS units (default: NULL for auto-sizing) |
height |
The height of the widget in pixels or CSS units (default: NULL for auto-sizing) |
element_id |
A unique identifier for the widget (default: NULL for auto-generated) |
... |
Additional arguments passed to create_maidr_html() |
Details
Uses iframe-based isolation to ensure MAIDR.js initializes properly. Each widget gets its own isolated JavaScript context where MAIDR.js can discover and initialize the SVG with maidr-data attribute.
Value
An htmlwidget object that can be displayed in RStudio, Shiny, or saved as HTML
MAIDR Widget Output for Shiny UI (Internal Alternative)
Description
Internal alternative Shiny UI function. This provides the same functionality as maidr_output() but is no longer recommended for direct use. Use maidr_output() and render_maidr() instead for better consistency.
Usage
maidr_widget_output(output_id, width = "100%", height = "400px")
Arguments
output_id |
The output variable to read the widget from |
width |
The width of the widget (default: "100percent") |
height |
The height of the widget (default: "400px") |
Value
A Shiny widget output function for use in UI
Map visual panel position to DOM panel name
Description
This function handles the mismatch between visual layout order (row-major) and DOM element generation order (column-major) in gridSVG.
Usage
map_visual_to_dom_panel(panel_info, gtable)
Arguments
panel_info |
Panel information from layout |
gtable |
Gtable object |
Details
Visual layout (row-major): 1 2 3 4
DOM order (column-major): 1 3 2 4
Value
Gtable panel name or NULL if not found
Handle HIGH-level Call
Description
Updates state when a HIGH-level plotting function is called.
Usage
on_high_level_call(device_id = grDevices::dev.cur(), call_index)
Arguments
device_id |
Graphics device ID |
call_index |
Index of the call in the calls list |
Value
NULL (invisible)
Handle LAYOUT Call
Description
Updates state when a layout function (par, layout) is called.
Usage
on_layout_call(device_id = grDevices::dev.cur(), function_name, args)
Arguments
device_id |
Graphics device ID |
function_name |
Name of layout function |
args |
Function arguments |
Value
NULL (invisible)
Open a temporary device to suppress default graphics window
Description
Called by wrappers when no device is open to prevent R from opening the default interactive graphics device.
Usage
open_maidr_temp_device()
Value
The device ID of the temp device
Organize subplots into 2D grid structure
Description
Organize subplots into 2D grid structure
Usage
organize_facet_grid(subplots, panel_layout)
Arguments
subplots |
List of processed subplot data |
panel_layout |
Panel layout information |
Value
2D grid structure
Convert Currency Prefix to ISO 4217 Code
Description
Maps common currency symbols to their ISO 4217 codes for use in JavaScript's Intl.NumberFormat.
Usage
prefix_to_currency_code(prefix)
Arguments
prefix |
Currency symbol (e.g., "$", the Euro sign, the Pound sign) |
Value
ISO 4217 currency code (e.g., "USD", "EUR", "GBP")
Process a single facet panel
Description
Process a single facet panel
Usage
process_facet_panel(
plot,
panel_info,
panel_data,
facet_groups,
gtable_panel_name,
built,
layout,
gtable,
format_config = NULL
)
Arguments
plot |
The original plot |
panel_info |
Panel information |
panel_data |
Panel-specific data |
facet_groups |
Facet group information |
gtable_panel_name |
Gtable panel name |
built |
Built plot data |
layout |
Layout information |
gtable |
Gtable object |
format_config |
Optional format configuration from maidr label functions |
Value
Processed panel data
Facet Processing Utilities
Description
Utility functions for processing faceted ggplot2 plots. These functions handle panel extraction, processing, and grid organization for faceted plots in a unified way.
Usage
process_faceted_plot_data(plot, layout, built, gtable, format_config = NULL)
Arguments
plot |
The faceted ggplot2 object |
layout |
Layout information |
built |
Built plot data |
gtable |
Gtable object |
format_config |
Optional format configuration from maidr label functions |
Value
List with organized subplot data in 2D grid format
Process a single patchwork panel
Description
Process a single patchwork panel
Usage
process_patchwork_panel(
leaf_plot,
panel_name,
panel_index,
row,
col,
layout,
gtable
)
Arguments
leaf_plot |
The leaf ggplot object |
panel_name |
Panel name from gtable |
panel_index |
Panel index |
row |
Panel row |
col |
Panel column |
layout |
Layout information |
gtable |
Gtable object |
Value
Processed panel data
Patchwork Processing Utilities
Description
Utility functions for processing patchwork multipanel compositions. These functions handle panel discovery, leaf extraction, and processing for patchwork plots in a unified way.
Usage
process_patchwork_plot_data(plot, layout, gtable)
Arguments
plot |
The patchwork plot object |
layout |
Layout information |
gtable |
Gtable object |
Value
List with organized subplot data in 2D grid format
Convert R Date Format to Intl.DateTimeFormat Options
Description
Converts R strftime format strings to JavaScript Intl.DateTimeFormat options.
Usage
r_date_format_to_intl_options(format)
Arguments
format |
R date format string (e.g., "%Y-%m-%d") |
Value
List of Intl.DateTimeFormat options
Convert R Date Format to JavaScript Function
Description
Creates a JavaScript function string that formats dates according to an R strftime format string. Used for complex date formats that cannot be represented by Intl.DateTimeFormat options alone.
Usage
r_date_format_to_js_function(format, tz = "UTC")
Arguments
format |
R date format string |
tz |
Timezone |
Value
JavaScript function body string
Render MAIDR Plot in Shiny Server
Description
Creates a Shiny render function for MAIDR widgets using htmlwidgets. This provides automatic dependency injection and robust JavaScript initialization.
Usage
render_maidr(expr, env = parent.frame(), quoted = FALSE)
Arguments
expr |
An expression that returns a ggplot object |
env |
The environment in which to evaluate expr |
quoted |
Is expr a quoted expression |
Value
A Shiny render function for use in server
Examples
if (interactive()) {
library(shiny)
library(ggplot2)
server <- function(input, output) {
output$myplot <- render_maidr({
ggplot(mtcars, aes(x = factor(cyl), y = mpg)) +
geom_bar(stat = "identity")
})
}
}
Render MAIDR Widget in Shiny Server (Internal Alternative)
Description
Internal alternative Shiny server function. This provides the same functionality as render_maidr() but is no longer recommended for direct use. Use maidr_output() and render_maidr() instead for better consistency.
Usage
render_maidr_widget(expr, env = parent.frame(), quoted = FALSE)
Arguments
expr |
An expression that returns a ggplot object |
env |
The environment in which to evaluate expr |
quoted |
Is expr a quoted expression |
Value
A Shiny render function for use in server
Replay Base R Plot from Device Storage
Description
Re-executes the recorded Base R plot calls to render the plot.
Usage
replay_base_r_plot(device_id)
Arguments
device_id |
The device ID to get calls from |
Replay Base R plot to native graphics device
Description
For unsupported plots, close the temp device and replay the plot calls to the native graphics device.
Usage
replay_to_native_device(device_id = grDevices::dev.cur())
Arguments
device_id |
The device ID to get plot calls from |
Value
NULL (invisible)
Reset Device State
Description
Resets the state for a device (called when storage is cleared).
Usage
reset_device_state(device_id = grDevices::dev.cur())
Arguments
device_id |
Graphics device ID |
Value
NULL (invisible)
Reset the global registry (mainly for testing)
Description
Reset the global registry (mainly for testing)
Usage
reset_global_registry()
Restore original functions
Description
Deactivates patching by flipping the active flag. Wrappers remain in the namespace but act as pass-through (calling the original function directly). This avoids modifying the locked namespace or the search path.
Usage
restore_original_functions()
Value
NULL (invisible)
Run MAIDR Example Plots
Description
Launches example plots demonstrating MAIDR's accessible visualization capabilities. Each example creates an interactive plot using 'show()'.
Usage
run_example(example = NULL, type = c("ggplot2", "base_r"))
Arguments
example |
Character string specifying which example to run. If 'NULL' (the default), lists all available examples. |
type |
Character string specifying the plot system to use. Either '"ggplot2"' (default) or '"base_r"'. |
Details
Available examples include various plot types such as bar charts, histograms, scatter plots, line plots, boxplots, heatmaps, and more.
Each example script creates a plot and calls 'show()' to display it in your default web browser with full MAIDR accessibility features including keyboard navigation and screen reader support.
Value
Invisibly returns 'NULL'. Called for its side effect of displaying an interactive plot in the browser or listing available examples.
See Also
[show()] for displaying plots, [save_html()] for saving to file
Examples
# List all available examples
run_example()
if (interactive()) {
# Run ggplot2 bar chart example
run_example("bar")
# Run Base R histogram example
run_example("histogram", type = "base_r")
}
Save Interactive Plot as HTML File
Description
Save a ggplot2 or Base R plot as a standalone HTML file with interactive MAIDR accessibility features.
Usage
save_html(plot = NULL, file = "plot.html", ...)
Arguments
plot |
A ggplot2 object or NULL for Base R auto-detection |
file |
File path where to save the HTML file (e.g., "plot.html") |
... |
Additional arguments passed to internal functions |
Value
The file path where the HTML was saved (invisibly)
Examples
# ggplot2 example
library(ggplot2)
p <- ggplot(mtcars, aes(x = factor(cyl), y = mpg)) +
geom_bar(stat = "identity")
maidr::save_html(p, tempfile(fileext = ".html"))
# Base R example (requires interactive session for function patching)
if (interactive()) {
barplot(c(10, 20, 30), names.arg = c("A", "B", "C"))
maidr::save_html(file = tempfile(fileext = ".html"))
}
Save HTML document to file
Description
Save HTML document to file
Usage
save_html_document(html_doc, file)
Arguments
html_doc |
An htmltools HTML document object |
file |
Output file path |
Scale Mapping Utilities for Faceted Plots
Description
These utilities handle the conversion between numeric positions and category labels in faceted plots, where ggplot2 converts categorical data to numeric positions for efficiency.
Set Internal Guard Flag
Description
Guards against recursive tracing by setting an internal flag.
Usage
set_internal_guard(value)
Arguments
value |
TRUE to set guard, FALSE to clear |
Value
NULL (invisible)
Display Interactive MAIDR Plot
Description
Display a ggplot2 or Base R plot as an interactive, accessible visualization using the MAIDR (Multimodal Access and Interactive Data Representation) system.
Usage
show(plot = NULL, shiny = FALSE, as_widget = FALSE, ...)
Arguments
plot |
A ggplot2 object or NULL for Base R auto-detection |
shiny |
If TRUE, returns just the SVG content instead of full HTML document |
as_widget |
If TRUE, returns an htmlwidget object instead of opening in browser |
... |
Additional arguments passed to internal functions |
Value
Invisible NULL. The plot is displayed in RStudio Viewer or browser as a side effect.
Examples
# ggplot2 example
library(ggplot2)
p <- ggplot(mtcars, aes(x = factor(cyl), y = mpg)) +
geom_bar(stat = "identity")
maidr::show(p)
# Base R example (requires interactive session for function patching)
if (interactive()) {
barplot(c(10, 20, 30), names.arg = c("A", "B", "C"))
maidr::show()
}
Update Device State
Description
Updates the state for a specific graphics device.
Usage
update_device_state(device_id = grDevices::dev.cur(), state)
Arguments
device_id |
Graphics device ID |
state |
Updated state list |
Value
NULL (invisible)
Wrap a single function
Description
This is only called during .onLoad when the namespace is still open. The wrapper checks is_patching_enabled() at runtime to decide whether to record calls or pass through.
Usage
wrap_function(function_name)
Arguments
function_name |
Name of the function to wrap |
Value
TRUE if successful, FALSE otherwise
Wrap S3 generic functions (lines and points)
Description
Special handling for S3 generics that can't be traced normally. Only called once during .onLoad when namespace is still open.
Usage
wrap_s3_generics()