Export the graph generated by rCharts in shiny application

I want to be able to export the charts generated in my shiny application using rCharts to Image and PDF formats. Is there any provision in the rCharts library for that?

I have earlier used ggvis, It gives an option for resizing the chart in the browser and also an option to download the chart in HTML or PNG format. Anything similar to that?

Edit 1:

I'm using nvd3 and polyCharts as my charting libraries currently.

Answers


To download as image or pdf you can use a$exporting(enabled = T), assuming your chart is called a.

library(rCharts)
a <- hPlot(Pulse ~ Height, data = MASS::survey, type = "scatter", group = "Exer")
a$exporting(enabled = T)
a


To follow up on my comment above, I was a bit too quick to respond, as the htmlwidget::saveWidget() function is meant for widgets developed under the htmlwidgets.org framework. However, rCharts has a similar function:

library(rCharts)

a <- nPlot(Pulse ~ Height, data = MASS::survey, type = "scatterChart", group = "Exer")
a$save("demo.html", standalone=TRUE)

Where 'demo.html' is standalone html file. Creating a png is as simple as taking a screenshot. Note that you can also call this function in a shiny app.


Need Your Help

Force Initialization of an enumerated type in Java

java enums enumeration

I am attempting to find a way to force Java to load/initialize an enumerated type (which is nested within a class that contains a static Map).