createWidget | R Documentation |
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
)
name |
Widget name (should match the base name of the YAML and JavaScript files used to implement the widget) |
x |
Widget instance data (underlying data to render and options that
govern how it's rendered). This value will be converted to JSON using
|
width |
Fixed width for widget (in css units). The default is
|
height |
Fixed height for widget (in css units). The default is
|
sizingPolicy |
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
|
package |
Package where the widget is defined (defaults to the widget name). |
dependencies |
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). |
elementId |
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. |
preRenderHook |
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. |
For additional details on developing widgets, see package vignettes:
vignette("develop_intro", package = "htmlwidgets")
.
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.