Helper-function to specify the embed argument to vegawidget(). These arguments reflect the options to the vega-embed library, which ultimately renders the chart specification as HTML.

vega_embed(
  renderer = c("canvas", "svg"),
  actions = NULL,
  defaultStyle = TRUE,
  config = NULL,
  patch = NULL,
  bind = NULL,
  ...
)

Arguments

renderer

character the renderer to use for the view. One of "canvas" (default) or "svg". See Vega docs for details.

actions

logical or named vector of logicals, determines if action links ("Export as PNG/SVG", "View Source", "Open in Vega Editor") are included with the embedded view. If the value is TRUE (default), all action links will be shown and none if the value is FALSE. This property can be a named vector of logicals that maps keys (export, source, compiled, editor) to logical values for determining if each action link should be shown. By default, export, source, and editor are TRUE and compiled is FALSE, but these defaults can be overridden. For example, if actions is list(export = FALSE, source = TRUE), the embedded visualization will have two links – "View Source" and "Open in Vega Editor".

defaultStyle

logical or character default stylesheet for embed actions. If set to TRUE (default), the embed actions are shown in a menu. Set to FALSE to use simple links. Provide a character string to set the style sheet.

config

character or list, a URL string from which to load a Vega/Vega-Lite or Vega-Lite configuration file, or a list of Vega/Vega-Lite configurations to override the default configuration options. If config is a URL, it will be subject to standard browser security restrictions. Typically this URL will point to a file on the same host and port number as the web page itself.

patch

JS function, list or character, A function to modify the Vega specification before it is parsed. Alternatively, an list that, when compiled to JSON, will meet JSON-Patch RFC6902. If you use Vega-Lite, the compiled Vega will be patched. Alternatively to the function or the list, a URL string from which to load the patch can be provided. This URL will be subject to standard browser security restrictions. Typically this URL will point to a file on the same host and port number as the web page itself.

bind

character

...

other named items, outlined in vega-embed options.

Value

list to to be used with vega-embed JavaScript library

Details

The most important arguments are renderer, actions, and defaultStyle:

  • The default renderer is "canvas".

  • The default for actions is NULL, which means that the export, source, and editor links are shown, but the compiled link is not shown.

    • To suppress all action links, call with actions = FALSE.

    • To change from the default for a given action link, call with a list: actions = list(editor = FALSE).

  • The default for defaultStyle is TRUE, which means that action-links are rendered in a widget at the upper-right corner of the rendered chart.

The vega-embed library has a lot more options, you can supply these as names arguments using ....

For example, it is ineffective to set the width and height parameters here when embedding a Vega-Lite specification, as they will be overridden by the value in the chart specification.

Examples

vega_embed(renderer = "svg")
#> $renderer
#> [1] "svg"
#> 
#> $defaultStyle
#> [1] TRUE
#>