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,
mode = NULL,
theme = NULL,
logLevel = NULL,
tooltip = NULL,
loader = NULL,
patch = NULL,
width = NULL,
height = NULL,
padding = NULL,
scaleFactor = NULL,
config = NULL,
editorUrl = NULL,
sourceHeader = NULL,
sourceFooter = NULL,
hover = NULL,
i18n = NULL,
downloadFileName = NULL,
formatLocale = NULL,
timeFormatLocale = NULL
)
character
the renderer to use for the view.
One of "canvas"
(default) or "svg"
.
See Vega docs
for details.
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 <U+2013> "View Source" and "Open in Vega Editor".
logical
or character
default stylesheet for embed actions
character
if specified, tells Vega-Embed to parse the spec
as vega or vega-lite. Vega-Embed will parse the $schema
url if the mode
is not specified. Vega-Embed will default to vega if neither mode,
nor $schema are specified.
character
if specified, tells Vega-Embed use the theme from
Vega Themes;
this is an experimental feature.
sets the current log level. See Vega docs for details.
JS
, logical
, or object
to provide a tooltip handler,
customize the default Vega Tooltip handler,
or disable the default handler.
list
, sets a custom Vega loader.
See Vega docs
for details.
JS
function or object, A function to modify the Vega
specification before it is parsed. Alternatively, an object that is used
to patch the Vega specification. If you use Vega-Lite, the compiled Vega
will be patched.
integer
, sets the view width in pixels.
See Vega docs
for details.
Note that Vega-Lite overrides this option.
integer
, sets the view height in pixels.
See Vega docs
for details.
Note that Vega-Lite overrides this option.
list
, sets the view padding in pixels.
See Vega docs
for details.
numeric
the number by which to multiply the width and
height (default 1) of an exported PNG or SVG image.
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.
character
, URL at which to open embedded Vega specs
in a Vega editor. Defaults to "http://vega.github.io/editor/"
.
Internally, Vega-Embed uses
HTML5 postMessage
to pass the specification information to the editor.
character
, HTML to inject into the `` tag of the
page generated by the "View Source" action link. For example, this
can be used to add code for syntax highlighting.
character
, HTML to inject into the end of the
page generated by the "View Source" action link. The text will be added
immediately before the closing `` tag.
logical
, enable hover event processing
list
, this property maps keys
(COMPILED_ACTION, EDITOR_ACTION, PNG_ACTION, SOURCE_ACTION, SVG_ACTION)
to string values for the action's text. By default, the text is in English.
character
, sets the file name (default: visualization
)
for charts downloaded using the png
or svg
action.
list
, sets the default locale definition for number formatting.
See the d3-format locale collection
for definition files for a variety of languages. Note that this is a global setting.
list
, sets the default locale definition for date/time formatting.
See the d3-time-format locale collection
for definition files for a variety of languages. Note that this is a global setting.
list
to to be used with vega-embed JavaScript library
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.
It is ineffective to set the width
and height
parameters here when
embedding a Vega-Lite specification, as they will be overridden by the values
in the chart specification.
# NOT RUN {
vega_embed(renderer = "svg")
# }
Run the code above in your browser using DataLab