staticPlot: Include a static image in a combinedWidgets

Description Usage Arguments Value Examples

View source: R/static_image.R

Description

staticPlot is a function that generates a static plot and then return the HTML code needed to include the plot in a combinedWidgets. staticImage is a more general function that generates the HTML code necessary to include any image file.

Usage

1
2
3
staticPlot(expr, width = 600, height = 400)

staticImage(file, style = "max-width:100%%;max-height:100%%")

Arguments

expr

Expression that creates a static plot.

width

Width of the image to create.

height

Height of the image to create.

file

path of the image to include.

style

CSS style to apply to the image.

Value

a shiny.tag object containing the HTML code required to include the image or the plot in a combinedWidgets object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
staticPlot(hist(rnorm(100)))

if (require(plotly)) {
  data(iris)

  combineWidgets(
    plot_ly(iris, x = ~Sepal.Length, type = "histogram", nbinsx = 20),
    staticPlot(hist(iris$Sepal.Length, breaks = 20), height = 300)
  )

  # You can also embed static images in the header, footer, left or right
  # columns of a combinedWidgets. The advantage is that the space allocated
  # to the static plot will be constant when the window is resized.

  combineWidgets(
    plot_ly(iris, x = ~Sepal.Length, type = "histogram", nbinsx = 20),
    footer = staticPlot(hist(iris$Sepal.Length, breaks = 20), height = 300)
  )
}

manipulateWidget documentation built on Oct. 5, 2021, 9:10 a.m.