handle_resize: Handlers and interactive inputs for plot sizing.

View source: R/handle_resize.R

handle_resizeR Documentation

Handlers and interactive inputs for plot sizing.

Description

Handlers and interactive inputs for plot sizing.

Usage

handle_resize(vis, on_resize)

plot_width(vis)

plot_height(vis)

Arguments

vis

Visualisation to listen to.

on_resize

Callback function with arguments:

width,height

Width and height in pixels

padding

A named list of four components giving the padding in each direction

session

The session, used to communicate with the browser

Examples

# This example just prints out the current dimensions to the console
mtcars %>% ggvis(~mpg, ~wt) %>%
  layer_points() %>%
  handle_resize(function(width, height, ...) cat(width, "x", height, "\n"))

# Use plot_width() and plot_height() to dynamically get the plot size
# inside the plot.
mtcars %>% ggvis(~mpg, ~wt) %>% layer_text(text := plot_width())
mtcars %>% ggvis(~mpg, ~wt) %>% layer_text(text := plot_height())

ggvis documentation built on May 29, 2024, 1:12 a.m.