ramnathv / rCharts

Interactive JS Charts from R
http://rcharts.io
Other
1.19k stars 654 forks source link

Add support for networks (graphs) libraries #557

Closed keeganhines closed 9 years ago

keeganhines commented 9 years ago

Hi @ramnathv et al

I'm thinking that people would like to be able to benefit from the handful of really nice js libraries for interactive plotting of networks. Some favorites are Sigmajs and VivaGraph, just to name a few. I'm happy to get started on this, but just want to get some feedback on a potential complication with adding support for network data.

The interface for rCharts functions tries to be agnostic to the required data formatting for each js library. In this way, once a typical dataframe is created, a call such as nPlot(y~x,...) will be pretty identical no matter which js library is being used. In all cases, we want to plot some dependent variable vs some independent variable, so this interface to [a-z]Plot will work.

I'm thinking that the data model is entirely dissimilar when we're talking about networks, so I don't know if this interface would persist. In order to visualize a network, you'd just want to know about the nodes (and any attributes they have) and the edges between nodes (and any attributes they have). As I see it, you might have a dataframe for each of those, and pass those to the plotting method such as graphPlot(nodes,edges,...) where maybe

nodes<-data.frame(names=c('Bill','Ted'),attribute=c('excellent','excellent'))
edges<-data.frame(source=c('Bill'),target=c('Ted'),weight=c(3))

It would be simple to write those dataframes to JSON and carry on with the js libraries for plotting networks, many of which rely on node list and edge list as the data formatting.

But again, this would be entirely different than everything else in rCharts. How might that inconsistency be resolved? Or should such an effort be separate from rCharts?

keeganhines commented 9 years ago

I see that something comparable has been implemented using htmlwidgets and d3 and is found in the package networkD3 - http://www.htmlwidgets.org/showcase_networkD3.html - so I suppose it's best to keep such things separate from rCharts going forward.

ramnathv commented 9 years ago

@keeganhines Yes htmlwidgets extends the idea of rCharts to a more generic framework that can support arbitrary javascript libraries. If you are still interested, we could talk so that you can implement widgets for VivaGraph and other network plotting libraries that you are aware of.

timelyportfolio commented 9 years ago

Would love to collaborate on this. Just wanted to make sure @keeganhines also saw the sigma.js skeleton widget used in Creating a Widget.

Happy New Year!