Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

toggleWidget

An HTML widget to toggle display of elements of a scene


Description

This function produces a button in an HTML scene that will toggle the display of items in the scene.

Usage

toggleWidget(sceneId, 
             ids = integer(), hidden = integer(),
             subscenes = NULL, 
             label = deparse(substitute(ids)), 
             ...)

Arguments

sceneId

The HTML id of the RGL scene being controlled, or an object as in playwidget.

ids, hidden

The RGL id numbers of the objects to toggle. Those in ids are initially shown; those in hidden are initially hidden.

subscenes

The subscenes in which to toggle the objects.

label

The label to put on the button.

...

Additional arguments to pass to playwidget.

Details

Like playwidget, this function is designed to work within the htmlwidgets framework. If the value is printed, the button will be inserted into the output.

It is also designed to work with magrittr-style pipes: the result of rglwidget or other widgets can be piped into it to add it to a display. It can also appear first in the pipeline, if sceneId is set to NA.

Value

A widget suitable for use in an Rmarkdown-generated web page, or elsewhere.

Author(s)

Duncan Murdoch

See Also

toggleButton for the older style of HTML control.

Examples

theplot <- plot3d(rnorm(100), rnorm(100), rnorm(100), col = "red")
widget <- rglwidget(height = 300, width = 300) %>%
  toggleWidget(theplot["data"], 
               hidden = theplot[c("xlab", "ylab", "zlab")], 
               label = "Points")
if (interactive() || in_pkgdown_example())
  widget

rgl

3D Visualization Using OpenGL

v0.106.8
GPL
Authors
Duncan Murdoch [aut, cre], Daniel Adler [aut], Oleg Nenadic [ctb], Simon Urbanek [ctb], Ming Chen [ctb], Albrecht Gebhardt [ctb], Ben Bolker [ctb], Gabor Csardi [ctb], Adam Strzelecki [ctb], Alexander Senger [ctb], The R Core Team [ctb, cph], Dirk Eddelbuettel [ctb], The authors of Shiny [cph], The authors of knitr [cph], Jeroen Ooms [ctb], Yohann Demont [ctb], Joshua Ulrich [ctb], Xavier Fernandez i Marin [ctb], George Helffrich [ctb], Ivan Krylov [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.