Create an HTML widget based on widget YAML and JavaScript contained within the specified package.
createWidget(
name,
x,
width = NULL,
height = NULL,
sizingPolicy = htmlwidgets::sizingPolicy(),
package = name,
dependencies = NULL,
elementId = NULL,
preRenderHook = NULL
)
Widget name (should match the base name of the YAML and JavaScript files used to implement the widget)
Widget instance data (underlying data to render and options that
govern how it's rendered). This value will be converted to JSON using
toJSON
and made available to the widget's
JavaScript renderValue
function.
Fixed width for widget (in css units). The default is
NULL
, which results in intelligent automatic sizing based on the
widget's container.
Fixed height for widget (in css units). The default is
NULL
, which results in intelligent automatic sizing based on the
widget's container.
Options that govern how the widget is sized in various
containers (e.g. a standalone browser, the RStudio Viewer, a knitr figure,
or a Shiny output binding). These options can be specified by calling the
sizingPolicy
function.
Package where the widget is defined (defaults to the widget name).
Additional widget HTML dependencies (over and above those defined in the widget YAML). This is useful for dynamic dependencies that only exist when selected widget options are enabled (e.g. sets of map tiles or projections).
Use an explicit element ID for the widget (rather than an automatically generated one). Useful if you have other JavaScript that needs to explicitly discover and interact with a specific widget instance.
A function to be run on the widget, just prior to rendering. It accepts the entire widget object as input, and should return a modified widget object.
An object of class htmlwidget
that will intelligently print
itself into HTML in a variety of contexts including the R console, within R
Markdown documents, and within Shiny output bindings.
For additional details on developing widgets, see package vignettes:
vignette("develop_intro", package = "htmlwidgets")
.