datastorm-open / rAmCharts

API for Amcharts
48 stars 17 forks source link

Examples for saving htmlwidgets and plots #68

Open nebuzoltanszuhai opened 7 years ago

nebuzoltanszuhai commented 7 years ago

I was playing a bit with the different charts available under rAmCharts (that looks impressive btw), and now wondering, if you plan to add functions or examples especially for htmlwidgets save, that I could not make working with this package. With leaflet, plotly, etc it is really easy.

Thanks, Zoltan

bthieurmel commented 7 years ago

Hi,

You have to save the plot object. A am object become a htmlwidgets after plot.

am <- amBoxplot(rnorm(100))
am
htmlwidgets::saveWidget(plot(am), file = "am.html")

We are adding a wrapper save function for next version

nebuzoltanszuhai commented 7 years ago

Thanks for the quick reply! Okay, then we are closer, I tried exactly the same with amBarplot and amAngularGauge where the same method did not work, it looks like it does work for the amBoxPlot without issue.

p <- amAngularGauge(...) htmlwidgets::saveWidget(p, file="test_widget.html")

of course parameters, bands are filled.

What error message I got: "Error in x$width : $ operator not defined for this S4 class"

bthieurmel commented 7 years ago

Yes, so you 've just have to add plot() saving widget, waiting for a simpler function.

p <- amAngularGauge(x = 10)
htmlwidgets::saveWidget(plot(p), file="test_widget.html")
nebuzoltanszuhai commented 7 years ago

Flawless, thanks! (I was sure I tried this as well, but apparently looks like not.)