Description Usage Arguments Value Author(s) References See Also Examples
d3Device
creates a graphics device instance.
All graphics commands sent to this device will generate
JavaScript code that will render the plot when viewed in a Web
browser.
The JavaScript code uses D3 to render the graphical elements.
d3Plot
is a wrapper function that atomically
creates a D3 device, evaluates the specified commands
to generate a graphical display and then closes the device.
1 2 3 |
dim |
a vector of two numbers specifying the width and height of the graphics canvas. The values are number of pixels. |
file |
the file to which the D3 JavaScript code will be written. This can be omitted and one can retrieve the code after closing the device and then post-process it to, for example, add interactivity. |
svgVarName |
the name of the JavaScript variable to which the top-level D3 object for the plot is assigned. This is different from the plot object which maintains references to the different types of graphical elements. |
div |
the name of the HTML element in which D3 will add the SVG elements |
plotVarName |
the name of the JavaScript variable to which the plot object will be assigned. We can use this variable to add JavaScript code to process elements of the plot. |
expr |
the R code to create the entire display |
... |
additional arguments passed to |
d3Device
creates a new graphics device and makes it active.
Both functions return a list with the following elements:
dev |
a reference to the C-level |
device |
a |
getCode |
a function that returns the JavaScript code generated by the device |
getCalls |
a function that returns the R call stack for each
object. This allows us to heuristically determine the purpose of each
graphical element, e.g. a line created in a call to |
getJSInfo |
a function that returns information about the generated
JavaScript code, i.e. the names of the JavaScript variables
( |
getCode
and getCalls
are functions that we call after
we have finished creating the graphical display.
These return information about the graphical elements that were
generated by the R graphics engine. The plot is not actually rendered
at this point in that the JavaScript code has not been evaluated.
That is done outside of R in a Web browser. However, these
functions return details about those graphical elements that will be
created in JavaScript.
Duncan Temple Lang
R graphics devices, D3
RGraphicsDevice
package
1 2 3 4 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.