Using Interactive D3.js charts from within Tiki with rNVD3

May 10, 2013
By

(This article was first published on UEB Blog. Musings on R, and kindly contributed to R-bloggers)

I've recently managed to reproduce my first charts using the nice package rNVD3 from Ramnath Vaidyanathan:
https://github.com/ramnathv/rNVD3

This rNVD3 package uses NVD3, which provides re-usable charts with d3.js, without taking away the power that d3.js brings with itself. But let's make a "Hello world" type of example, with the minimum complexity in it.

For this, I just needed to copy one of Ramnath's examples, but I will save the html to disk, with something like object$save('foo.html') instead of object$printChart('foo.html'). used in his example

And then, you can load the html in a wiki page with an iframe. Easy.

Proof of concept

A working proof-of-concept reusing your rNVD3 package can be found here:
http://r-es.org/r_test8

The main code is this one:

Error Plugin execution pending approval

This plugin was recently added or modified. Until an editor of the site validates the parameters, execution will not be possible.

Error Plugin execution pending approval

This plugin was recently added or modified. Until an editor of the site validates the parameters, execution will not be possible.

Results

And once everything is ready in your system (all packages installed, etc), you'll see something like this:

Click to enlarge
Click to enlarge


And when you change from "Grouped display" to "Stacked display", you will see a transition of data changing from one display to the other in real time in your browser, ending with this:

Click to enlarge
Click to enlarge

Details

The Web platform to manage the whole thing is Tiki ( https://tiki.org ), and the communication with R is handled by PluginR ( https://doc.tiki.org/PluginR ), as usual with most of our work.

This example has been added as a new test (r_test7) in the Tiki configuration profile http://profiles.tiki.org/r_test . Therefore, when you apply ( ~ install) this profile in your Tiki, you'll have this whole test loaded in a new wiki page, handy for you to play with it.

Future work

For later I leave my goal to achieve running some shiny app from a Wiki page in Tiki (in case this is possible!, which I'm not sure yet, maybe some new development is needed)

First impressions

For the time being, I'm quite glad with the first impression by the rNVD3 author (Ramnath Vaidyanathan) when he first knew about this proof-of-concept a few hours ago:

Ramnath Vaidyanathan wrote:
First off, nice work embedding it in a Wiki. A key objective of rCharts is to make it easy to share charts and this is a great way to do it.


Oh well, thanks for you nice words. Some more work is in the oven with PluginR, so stay tuned! :-)

To leave a comment for the author, please follow the link and comment on his blog: UEB Blog. Musings on R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.