l_layer_callback: Tour Layer Configuration

Description Usage Arguments Details Value Examples

View source: R/l_layer_callback.R

Description

Mainly used in the 2D (or 1D) tour interactive layer configuration

Usage

1
l_layer_callback(target, layer, ...)

Arguments

target

either a 'l_tour' object or a loon widget

layer

the layer need to be modified

...

some useful info for the layer configuration (i.e. tours, projections, etc)

Details

It is a S3 method. The object class is determined by the layer **label**

Value

this callback function does not return any object. As the slider bar is scrolled, for the specified layer, the callback function will be fired and the layer will be configured.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
if(interactive() && requireNamespace("tourr")) {
  # 1D tour
  p <- l_tour(iris[, -5], tour = tourr::grand_tour(1L))
  # add layer density
  l <- l_layer(l_getPlots(p),
               stats::density(p['x']),
               label = "density")

  # as we scroll the bar, the density curve does not change
  # unless the following function is executed
  l_layer_callback.density <- function(target, layer, ...) {

      layer <- loon::l_create_handle(c(l_getPlots(target), layer))
      den <- stats::density(target['x'])

      loon::l_configure(layer,
                        x = den$x,
                        y = den$y)

      invisible()
  }
}

loon.tourr documentation built on Oct. 27, 2021, 5:09 p.m.