Hi! I'm Nicolas and I'm interested in information visualization, JavaScript and web standards.
I currently work as a Data Visualization Scientist at Twitter. I wrote PhiloGL, the JavaScript InfoVis Toolkit and V8-GL.
I've been doing some work on the JIT lately, fixing some bugs and adding some new features.
Some important changes to mention are:
A complete refactoring of the Spacetree. That code was not clear. I also binded the ST to the Animation object used by the Hypertree and RGraph. This allows it to have easeIn and easeOut transitions. I also updated the documentation for this class.
Main functionality is now packaged under the Tree Class, making a good distinction between generic code (say Tree.Util for example) and more specific code (like the Tree.Geometry object, or Tree.Label).
Here's the old example of an "infinite" spacetree, done with the "new code".
Hypertree and RGraphs can now handle weighted nodes and edges in trees and graphs. The same goes for the Spacetree, although I have not tested that yet.
Weighted nodes:
This goes only for the RGraph and the Hypertree, since I don't see a clear representation of weighted nodes in the Spacetree, and the Treemap already represents weight either with size or color.
Weighted nodes are enabled when setting Config.allowVariableNodeDiameters = true.
Remember what a dataset is? A dataset is a reference to the property data of a JSON node representation. There you can store data by appending { key:'someKey', value:'someValue'} objects to the data array property.
The value of the first object of the data property will be taken in account to calculate the nodes diameters. You will also want to specify two properties of the config object, the nodeRangeDiameters property:
//Property: nodeRangeDiameters//Diameters range. For variable node weights.nodeRangeDiameters:{min:10,max:35},
Which specifies the specific range of your nodes diameters. Nodes will range from 10px to 35px as default. The other property is the nodeRangeValues:
//Property: nodeRangeValues// The interval of the values of the first object of your dataSet.// A superset of the values can also be specified.nodeRangeValues:{min:1,max:35},
You'll need to specify range values for your first dataset object value. This is all the information we need to know in order to plot a RGraph or Hypertree with weighted nodes. Here's an example of a K6 Hypergraph with variable node diameters (and weighted edges).
A note on usability
There's an extra property for the Hypertree Config object called Config.transformNodes. When applying a moebius transformation of the tree (that is, when the tree moves), tree nodes and edges change their proportion. This is not a good feature if you're planning to add weighted nodes in your Hypertree, since they will be deformed and thus the user won't be able to tell which node is bigger than which. You can set this property to false when using weighted nodes on your visualization.
Weighted edges
Two new methods have been included in the controller object, these are onBeforePlotLine(adj); and onAfterPlotLine(adj);. Both receive an adjacency object, which has the following structure:
varadj={nodeFrom:""/* A node connected with this adjacence */,nodeTo:""/* Other node connected with this adjacence */,data:{//An object storing your custom information.weight:w}};
Use the two controller methods to change the canvas lineWidth property or the stroke color (more information on that here). For example,
/* some code... */varrgraph=newRGraph(canvas,{//Use onBeforePlotLine and onAfterPlotLine controller//methods to adjust your canvas lineWidth//parameter in order to plot weighted edges on //your graph. You can also change the color of the lines.onBeforePlotLine:function(adj){lineW=canvas.getContext().lineWidth;canvas.getContext().lineWidth=adj.data.weight;},onAfterPlotLine:function(adj){canvas.getContext().lineWidth=lineW;},/* some other code*/
Ok, but how do I store edge weights?
The JSON Graph structure has been extended to the following form (notice that the old Graph structure is still accepted).
varjson=[{"id":"aUniqueIdentifier","name":"usually a nodes name","data":[{key:"some key",value:"some value"},{key:"some other key",value:"some other value"}],"adjacencies":[{nodeTo:"aNodeId",data:{}//put whatever you want here }//more objects like these...]}/* ... more nodes here ... */];
JSON Tree structures
For JSON Trees is simpler. If you have a Node A and B is a child of A, then store in Bs dataset a property concerning the weight of the edge A-B. These nodes will be stored in the adj object onBeforePlotLine and onAfterPlotLine. You can access them by doing adj.nodeFrom and adj.nodeTo.
Here's an example of a K6 RGraph with weighted nodes and edges.
The last example also shows a new feature for the RGraph, polar interpolation. You will notice that node transitions are different from previous examples. You can change the interpolation by setting Config.interpolation to 'polar' or 'linear'. I'll make a more detailed explanation for polar interpolation in some other post. If you want to know more about the cool features of the paper inspiring the RGraph, you can see this post.
API Changes
These features introduced an api change that has already been updated in all tutorials, although I have not checked for errors yet (will do today and/or tomorrow). You should not set the controller property from the ST, RGraph, Treemaps and Hypertree instances. That is, you can't do:
I updated all examples packaged with the library, also adding the two K6 examples showed above. Code that depends on the Mootools library (that is, the example files and the Treemap visualization) has been updated to the final 1.2 version of the Mootools library. This library is shipped as an extra with the JIT.
Special thanks to Rene Becker for pointing bugs and Daniel Herrero for suggesting cool performance improvements.
Remember that you can post any question, suggestion or comment on the JIT google group.
Get the library already!
Bye!