Title: | Visualization Package for CanvasXpress in R |
---|---|
Description: | Enables creation of visualizations using the CanvasXpress framework in R. CanvasXpress is a standalone JavaScript library for reproducible research with complete tracking of data and end-user modifications stored in a single PNG image that can be played back. See <https://www.canvasxpress.org> for more information. |
Authors: | Isaac Neuhaus [aut], Connie Brett [aut, cre] |
Maintainer: | Connie Brett <[email protected]> |
License: | GPL-3 |
Version: | 1.50.5 |
Built: | 2024-11-22 20:32:17 UTC |
Source: | https://github.com/neuhausi/canvasxpress |
A package to assist in creating visualizations in CanvasXpress in R.
CanvasXpress is a standalone JavaScript library for reproducible research with complete tracking of data and end-user modifications stored in a single PNG image that can be played back for an extensive set of visualizations.
browseVignettes(package = "canvasXpress")
Maintainer: Connie Brett [email protected]
Authors:
Isaac Neuhaus [email protected]
Useful links:
Report bugs at https://github.com/neuhausi/canvasXpress/issues
Custom HTML widget creation function based on widget YAML and JavaScript for use in any html-compatible context
canvasXpress( data = NULL, smpAnnot = NULL, varAnnot = NULL, graphType = "Scatter2D", events = NULL, afterRender = NULL, pretty = FALSE, digits = 4, width = 600, height = 400, destroy = FALSE, ... )
canvasXpress( data = NULL, smpAnnot = NULL, varAnnot = NULL, graphType = "Scatter2D", events = NULL, afterRender = NULL, pretty = FALSE, digits = 4, width = 600, height = 400, destroy = FALSE, ... )
data |
data.frame-, matrix-, list- , or ggplot- classed object |
smpAnnot |
additional data that applies to samples (columns) |
varAnnot |
additional data that applies to variables (rows) |
graphType |
type of graph to be plotted - default = "Scatter2D" |
events |
user-defined events (e.g. mousemove, mouseout, click and dblclick) |
afterRender |
event triggered after rendering |
pretty |
print tagged code (JSON/HTML) nicely - default = FALSE |
digits |
display digits - default = 4 |
width |
plot width (valid CSS units) - default = 600px |
height |
plot height (valid CSS units) - default = 400px |
destroy |
used to indicate removal of a plot - default = FALSE |
... |
additional parameters passed to canvasXpress |
htmlwidgets object
Piping is supported (both the magrittr ' canvasXpress object into data parameter. Any new parameters will be added to the original configuration of the object, any parameters with data that existed before will be replaced, and any parameters set to null will be removed. It is important to note that primary data changes are not allowed in this construct - which means that anything specified by using the data, varAnnot, or smpAnnot parameters cannot be changed from the original values.
Custom HTML widget creation function based on widget YAML and JavaScript for use in any html-compatible context using raw JSON input. Validation of data and configuration is deferred completely to the canvasXpress JavaScript library.
canvasXpress.json( json, pretty = FALSE, digits = 4, width = 600, height = 400, destroy = FALSE )
canvasXpress.json( json, pretty = FALSE, digits = 4, width = 600, height = 400, destroy = FALSE )
json |
JSON string or object |
pretty |
print tagged code (JSON/HTML) nicely - default = FALSE |
digits |
display digits - default = 4 |
width |
plot width (valid CSS units) - default = 600px |
height |
plot height (valid CSS units) - default = 400px |
destroy |
used to indicate removal of a plot - default = FALSE |
For the formatting of the JSON input object see
**Note:** this function is intended for use by advanced users who are experimenting with or need to utilize the json-formatted input to canvasXpress and are comfortable debugging chart issues in a browser (JavaScript) context instead of in R.
htmlwidgets object
my_json <- '{ "data": {"y": { "vars": ["Performance"], "smps": ["January"], "data": [[85]] }}, "config": { "graphType": "Meter", "meterType": "gauge" }}' canvasXpress.json(my_json)
my_json <- '{ "data": {"y": { "vars": ["Performance"], "smps": ["January"], "data": [[85]] }}, "config": { "graphType": "Meter", "meterType": "gauge" }}' canvasXpress.json(my_json)
Output creation function for canvasXpressOutput in Shiny applications and interactive Rmd documents
canvasXpressOutput(outputId, width = "100%", height = "400px")
canvasXpressOutput(outputId, width = "100%", height = "400px")
outputId |
shiny unique ID |
width |
width of the element - default = 100% |
height |
height of the element - default = 400px |
Output function that enables the use of the widget in applications
This function creates and returns a stand-alone HTML page containing the given canvasXpress object. Width and height can be inferred from the canvasXpress object (default) or overridden for the page output.
cxHtmlPage(chartObject, width = NULL, height = NULL)
cxHtmlPage(chartObject, width = NULL, height = NULL)
chartObject |
a canvasXpress plot object |
width |
plot width override for the HTML page (valid CSS units) - default = NULL |
height |
plot height override for the HTML page (valid CSS units) - default = NULL |
a character string containing a self-contained html page
## Not run: my_chart <- canvasXpress(data = data.frame(Sample1 = c(33, 48), Sample2 = c(44, 59), Sample3 = c(55, 6)), graphType = "Bar", title = "Example Bar Chart", width = "600px") # create a page using the chart dimensions on my_chart html_page <- cxHtmlPage(my_chart) # or change the chart width/height for this page: html_page <- cxHtmlPage(my_chart, width = "100%", height = "70vh") # save page for viewing/sharing writeLines(html_page, tempfile(fileext = ".html")) ## End(Not run)
## Not run: my_chart <- canvasXpress(data = data.frame(Sample1 = c(33, 48), Sample2 = c(44, 59), Sample3 = c(55, 6)), graphType = "Bar", title = "Example Bar Chart", width = "600px") # create a page using the chart dimensions on my_chart html_page <- cxHtmlPage(my_chart) # or change the chart width/height for this page: html_page <- cxHtmlPage(my_chart, width = "100%", height = "70vh") # save page for viewing/sharing writeLines(html_page, tempfile(fileext = ".html")) ## End(Not run)
This function runs one of the available shiny example applications. To see the list of available example applications run the function with no inputs
cxShinyExample(example = NULL)
cxShinyExample(example = NULL)
example |
character name of a valid example application. |
Launches a running shiny example application
Converts a ggplot object to a list that can be used by CanvasXpress.
ggplot.as.list(o, ...)
ggplot.as.list(o, ...)
o |
the ggplot object |
... |
additional parameters to the function |
Render function for canvasXpressOutput in Shiny applications and interactive Rmd documents
renderCanvasXpress(expr, env = parent.frame(), quoted = FALSE)
renderCanvasXpress(expr, env = parent.frame(), quoted = FALSE)
expr |
expression used to render the canvasXpressOutput |
env |
environment to use - default = parent.frame() |
quoted |
whether the expression is quoted - default = FALSE |
Render function that enables the use of the widget in applications
When there exists a need to visually remove a plot from a Shiny application when it is not being immediately replaced with a new plot use the destroy option as in:
renderCanvasXpress({canvasXpress(destroy = TRUE)})