Learn R Programming

maidr (version 0.1.2)

maidr_widget: 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, ...)

Value

An htmlwidget object that can be displayed in RStudio, Shiny, or saved as HTML

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.