<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>noumena</title>
	<atom:link href="http://blog.thejit.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.thejit.org</link>
	<description>A blog about the JIT</description>
	<pubDate>Wed, 02 Jul 2008 19:51:18 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Feeding JSON graph structures to the JIT</title>
		<link>http://blog.thejit.org/2008/07/02/feeding-json-graph-structures-to-the-jit/</link>
		<comments>http://blog.thejit.org/2008/07/02/feeding-json-graph-structures-to-the-jit/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 19:49:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>

		<category><![CDATA[graph]]></category>

		<category><![CDATA[hypertree]]></category>

		<category><![CDATA[information visualization]]></category>

		<category><![CDATA[JIT]]></category>

		<category><![CDATA[rgraph]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=19</guid>
		<description><![CDATA[Version 1.0.3a of the JIT allows you to load graph structures to the RGraph and Hypertree objects. I chose a different JSON structure for graphs, since JSON tree structures don&#8217;t seem conceptually suitable for this task.
Hypertree and RGraph objects have a new method called loadGraphFromJSON(json [,i]) that takes a graph structure (described below) and optionally [...]]]></description>
			<content:encoded><![CDATA[<p>Version <a href="/wp-content/jit-1.0.3a.zip" target="_blank">1.0.3a</a> of the JIT allows you to load graph structures to the RGraph and Hypertree objects. I chose a different JSON structure for graphs, since JSON tree structures don&#8217;t seem conceptually suitable for this task.<br />
Hypertree and RGraph objects have a new method called <b>loadGraphFromJSON(json [,i])</b> that takes a graph structure (described below) and optionally an index to set a particular node as root for the visualization. Please refer to the <a href="/wp-content/jit-1.0a/doc/rgraph/files/Rgraph-js.html#RGraph.loadGraphFromJSON" target="_blank">documentation for more information</a>.</p>
<h4>The graph structure</h4>
<p>The JSON graph structure is an array of nodes, each having as properties:</p>
<ul>
<li><b>id</b> a <b>unique</b> identifier for the node.</li>
<li><b>name</b> a node&#8217;s name.</li>
<li><b>data</b> The data property contains a <em>dataset</em>. That is, an array of key-value objects defined by the user. Roughly speaking, this is where you can put some extra information about your node. You&#8217;ll be able to access this information at different stages of the computation of the JIT visualizations by using a controller.
</li>
<li><b>adjacencies</b> An array of strings each representing a nodes id.
</ul>
<p>For example,</p>
<pre name="code" class="js:nogutter:nocontrols">
var json = [
{
	"id": "aUniqueIdentifier",
	"name": "usually a nodes name",
	"data": [
	    {key:"some key",       value: "some value"},
		{key:"some other key", value: "some other value"}
	],
	"adjacencies": ["anotherUniqueIdentifier", "yetAnotherUniqueIdentifier" /* ... */]
} /* ... more nodes here ... */ ];
</pre>
<p>I did a small <a href="/wp-content/jit-1.0a/examples/rgraph2.html" target="_blank">example</a> of a K6 rendered with a RGraph. The JSON graph structure used for this example is:</p>
<div style="height:300px;overflow:scroll;">
<pre name="code" class="js:nogutter:nocontrols">var json= [
    {"id":"node0",
     "name":"node0 name",
     "data":[
        {"key":"some key",
         "value":"some value"},
        {"key":"some other key",
         "value":"some other value"}],
     "adjacencies":["node1","node2","node3","node4","node5"]},
    {"id":"node1",
     "name":"node1 name",
     "data":[
        {"key":"some key",
         "value":"some value"},
        {"key":"some other key",
         "value":"some other value"}],
     "adjacencies":["node0","node2","node3","node4","node5"]},
    {"id":"node2",
     "name":"node2 name",
     "data":[
        {"key":"some key",
         "value":"some value"},
        {"key":"some other key",
         "value":"some other value"}],
     "adjacencies":["node0","node1","node3","node4","node5"]},
    {"id":"node3",
     "name":"node3 name",
     "data":[
        {"key":"some key",
         "value":"some value"},
        {"key":"some other key",
         "value":"some other value"}],
     "adjacencies":["node0","node1","node2","node4","node5"]},
    {"id":"node4",
     "name":"node4 name",
     "data":[
        {"key":"some key",
         "value":"some value"},
        {"key":"some other key",
         "value":"some other value"}],
     "adjacencies":["node0","node1","node2","node3","node5"]},
    {"id":"node5",
     "name":"node5 name",
     "data":[
        {"key":"some key",
         "value":"some value"},
        {"key":"some other key",
         "value":"some other value"}],
     "adjacencies":["node0","node1","node2","node3","node4"]}];
</pre>
</div>
<p>You can post any question at the <a href="http://groups.google.com/group/javascript-information-visualization-toolkit">google group</a> for this project.<br />
Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2008/07/02/feeding-json-graph-structures-to-the-jit/feed/</wfw:commentRss>
		</item>
		<item>
		<title>JIT version 1.0.2a</title>
		<link>http://blog.thejit.org/2008/06/08/jit-version-102a/</link>
		<comments>http://blog.thejit.org/2008/06/08/jit-version-102a/#comments</comments>
		<pubDate>Sun, 08 Jun 2008 22:16:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>

		<category><![CDATA[version]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=18</guid>
		<description><![CDATA[Just dropping by to say I just released version 1.0.2a of the javascript infovis toolkit. You can also download it from the main page.
It fixes some known bugs on the Spacetree and Hyperbolic Tree visualizations.
I&#8217;d like to thank OpenCRX and Charles D. Aylward for pointing those errors out.
I also used version 1.4 of Natural Docs [...]]]></description>
			<content:encoded><![CDATA[<p>Just dropping by to say I just released <a href="http://blog.thejit.org/wp-content/jit-1.0.2a.zip" target="_blank">version 1.0.2a</a> of the javascript infovis toolkit. You can also download it from the <a href="http://thejit.org">main page</a>.<br />
It fixes some known bugs on the Spacetree and Hyperbolic Tree visualizations.<br />
I&#8217;d like to thank <a href="http://www.opencrx.org/">OpenCRX</a> and Charles D. Aylward for pointing those errors out.<br />
I also used version 1.4 of Natural Docs to make the docs. <br />
Please let me know if you find more errors.<br />
Bye! <img src='http://blog.thejit.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2008/06/08/jit-version-102a/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Animated exploration of Graphs with radial layout video</title>
		<link>http://blog.thejit.org/2008/06/02/animated-exploration-of-graphs-with-radial-layout-video/</link>
		<comments>http://blog.thejit.org/2008/06/02/animated-exploration-of-graphs-with-radial-layout-video/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 00:23:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[graph]]></category>

		<category><![CDATA[information visualization]]></category>

		<category><![CDATA[radial layout]]></category>

		<category><![CDATA[tree]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=17</guid>
		<description><![CDATA[I ran into this youtube video that presents all the features to be included in the RGraph visualization. Some of them were mentioned in the previous post (polar interpolation, child ordering), other are already included with the library (the first animation constraint mentioned in the video, ease-in and ease-out transitions, etc). Anyway, I thought this [...]]]></description>
			<content:encoded><![CDATA[<p>I ran into this youtube video that presents all the features to be included in the RGraph visualization. Some of them were mentioned in the previous post (polar interpolation, child ordering), other are already included with the library (the first animation constraint mentioned in the video, ease-in and ease-out transitions, etc). Anyway, I thought this could be interesting.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="wmode" value="transparent" /><param name="src" value="http://www.youtube.com/v/OPX5iGro_lA&amp;hl=en" /><embed type="application/x-shockwave-flash" width="425" height="355" src="http://www.youtube.com/v/OPX5iGro_lA&amp;hl=en" wmode="transparent"></embed></object></p>
<p><em><br />
If you can&#8217;t see the embedded video, please access the video by clicking <a href="http://youtube.com/watch?v=OPX5iGro_lA" target="_blank">here</a>.<br />
</em></p>
<p>You can also see the &#8220;original&#8221; paper <a href="http://bailando.sims.berkeley.edu/papers/infovis01.htm">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2008/06/02/animated-exploration-of-graphs-with-radial-layout-video/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Further work on JIT</title>
		<link>http://blog.thejit.org/2008/05/20/further-work-on-jit-10a/</link>
		<comments>http://blog.thejit.org/2008/05/20/further-work-on-jit-10a/#comments</comments>
		<pubDate>Tue, 20 May 2008 13:33:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>

		<category><![CDATA[information visualization]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[JIT]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=15</guid>
		<description><![CDATA[I&#8217;m very happy with this first JavaScript Infovis Toolkit release, and I&#8217;m already working on fixing some known bugs and adding features for the next release of this library.
For the next step I&#8217;ll be focusing on fixing bugs, refactoring code, adding some features and improving the documentation.
Some of the things you&#8217;ll find in my TODO [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m very happy with this first JavaScript Infovis Toolkit release, and I&#8217;m already working on fixing some known bugs and adding features for the next release of this library.<br />
For the next step I&#8217;ll be focusing on fixing bugs, refactoring code, adding some features and improving the documentation.<br />
Some of the things you&#8217;ll find in my TODO list are:</p>
<ul>
<li>For RGraphs:
<ul>
<li>Add polar interpolation in animations.</li>
<li>Mantain Child ordering during transitions.</li>
<li>Change node diameters based on the first dataset object value.</li>
<li>Graph support (trees with cycles&#8230;)</li>
</ul>
</li>
<li>For the ST:
<ul>
<li>Code refactoring.</li>
<li>Performance improvements (bind with the Animation object).</li>
<li>Support for IE.</li>
</ul>
</li>
<li>For Hypertrees:
<ul>
<li>Bug fix (node diameters, multilevel display).</li>
<li>Graph support, (although it might be supporting Graph structures already).</li>
</ul>
</li>
<li>Treemaps
<ul>
<li>Bug fix (mostly on computing rectangles dimensions).</li>
</ul>
</li>
</ul>
<p>Before adding some radical features (binding visualizations with real time mutable data, etc.) I really want to have a strong API, and in order to do that, I must do some research on my own. <br />
Don&#8217;t forget you have some quick <a href="http://blog.thejit.org/?p=12">tutorials</a> <a href="http://blog.thejit.org/?p=11">on</a> <a href="http://blog.thejit.org/?p=10">the</a> <a href="http://blog.thejit.org/?p=9">visualizations</a>. Also, the <a href="http://blog.thejit.org/wp-content/jit-1.0a/doc/hypertree" target="_blank">Hypertree</a>, <a href="http://blog.thejit.org/wp-content/jit-1.0a/doc/spacetree/" target="_blank">ST</a>, <a href="http://blog.thejit.org/wp-content/jit-1.0a/doc/rgraph" target="_blank">RGraph</a> and <a href="http://blog.thejit.org/wp-content/jit-1.0a/doc/treemap" target="_blank">Treemap</a> have some object references. Finally, there&#8217;s a Google Group about the JIT <a href="http://groups.google.com/group/javascript-information-visualization-toolkit" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2008/05/20/further-work-on-jit-10a/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RGraph quick tutorial</title>
		<link>http://blog.thejit.org/2008/05/07/rgraph-quick-tutorial/</link>
		<comments>http://blog.thejit.org/2008/05/07/rgraph-quick-tutorial/#comments</comments>
		<pubDate>Wed, 07 May 2008 18:37:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>

		<category><![CDATA[information visualization]]></category>

		<category><![CDATA[JIT]]></category>

		<category><![CDATA[radial graph]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blogngb.woot.com.ar/?p=12</guid>
		<description><![CDATA[This tutorial requires you to have read Feeding JSON tree structures to the JIT and on controllers first.
Hi, this is going to be a quick tutorial on how to set the RGraph up and running.
We are going to work with this tree JSON structure:

var json = {"id":"node02",
 "name":"0.2",
 "data":[
    {"key":"key1",
   [...]]]></description>
			<content:encoded><![CDATA[<p><em>This tutorial requires you to have read <a href="http://blog.thejit.org/?p=7">Feeding JSON tree structures to the JIT</a> and <a href="http://blog.thejit.org/?p=8">on controllers</a> first</em>.</p>
<p>Hi, this is going to be a quick tutorial on how to set the RGraph up and running.</p>
<p>We are going to work with this tree JSON structure:</p>
<div style="height:300px;overflow:scroll;">
<pre name="code" class="js:nogutter:nocontrols">var json = {"id":"node02",
 "name":"0.2",
 "data":[
    {"key":"key1",
     "value":8},
    {"key":"key2",
     "value":-88}],
 "children":[
    {"id":"node13",
     "name":"1.3",
     "data":[
        {"key":"key1",
         "value":8},
        {"key":"key2",
         "value":74}],
     "children":[
        {"id":"node24",
         "name":"2.4",
         "data":[
            {"key":"key1",
             "value":10},
            {"key":"key2",
             "value":55}],
         "children":[]},
        {"id":"node25",
         "name":"2.5",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":67}],
         "children":[]},
        {"id":"node26",
         "name":"2.6",
         "data":[
            {"key":"key1",
             "value":5},
            {"key":"key2",
             "value":-50}],
         "children":[]},
        {"id":"node27",
         "name":"2.7",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":10}],
         "children":[]},
        {"id":"node28",
         "name":"2.8",
         "data":[
            {"key":"key1",
             "value":2},
            {"key":"key2",
             "value":-69}],
         "children":[]},
        {"id":"node29",
         "name":"2.9",
         "data":[
            {"key":"key1",
             "value":3},
            {"key":"key2",
             "value":98}],
         "children":[]},
        {"id":"node210",
         "name":"2.10",
         "data":[
            {"key":"key1",
             "value":6},
            {"key":"key2",
             "value":12}],
         "children":[]},
        {"id":"node211",
         "name":"2.11",
         "data":[
            {"key":"key1",
             "value":2},
            {"key":"key2",
             "value":-95}],
         "children":[]}]},
    {"id":"node112",
     "name":"1.12",
     "data":[
        {"key":"key1",
         "value":1},
        {"key":"key2",
         "value":96}],
     "children":[
        {"id":"node213",
         "name":"2.13",
         "data":[
            {"key":"key1",
             "value":6},
            {"key":"key2",
             "value":-58}],
         "children":[]},
        {"id":"node214",
         "name":"2.14",
         "data":[
            {"key":"key1",
             "value":9},
            {"key":"key2",
             "value":-42}],
         "children":[]},
        {"id":"node215",
         "name":"2.15",
         "data":[
            {"key":"key1",
             "value":10},
            {"key":"key2",
             "value":92}],
         "children":[]},
        {"id":"node216",
         "name":"2.16",
         "data":[
            {"key":"key1",
             "value":7},
            {"key":"key2",
             "value":-15}],
         "children":[]},
        {"id":"node217",
         "name":"2.17",
         "data":[
            {"key":"key1",
             "value":3},
            {"key":"key2",
             "value":29}],
         "children":[]},
        {"id":"node218",
         "name":"2.18",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":-59}],
         "children":[]},
        {"id":"node219",
         "name":"2.19",
         "data":[
            {"key":"key1",
             "value":3},
            {"key":"key2",
             "value":21}],
         "children":[]},
        {"id":"node220",
         "name":"2.20",
         "data":[
            {"key":"key1",
             "value":2},
            {"key":"key2",
             "value":78}],
         "children":[]}]},
    {"id":"node121",
     "name":"1.21",
     "data":[
        {"key":"key1",
         "value":3},
        {"key":"key2",
         "value":53}],
     "children":[
        {"id":"node222",
         "name":"2.22",
         "data":[
            {"key":"key1",
             "value":5},
            {"key":"key2",
             "value":10}],
         "children":[]},
        {"id":"node223",
         "name":"2.23",
         "data":[
            {"key":"key1",
             "value":10},
            {"key":"key2",
             "value":21}],
         "children":[]},
        {"id":"node224",
         "name":"2.24",
         "data":[
            {"key":"key1",
             "value":6},
            {"key":"key2",
             "value":-32}],
         "children":[]},
        {"id":"node225",
         "name":"2.25",
         "data":[
            {"key":"key1",
             "value":5},
            {"key":"key2",
             "value":-42}],
         "children":[]},
        {"id":"node226",
         "name":"2.26",
         "data":[
            {"key":"key1",
             "value":2},
            {"key":"key2",
             "value":75}],
         "children":[]},
        {"id":"node227",
         "name":"2.27",
         "data":[
            {"key":"key1",
             "value":1},
            {"key":"key2",
             "value":-74}],
         "children":[]},
        {"id":"node228",
         "name":"2.28",
         "data":[
            {"key":"key1",
             "value":2},
            {"key":"key2",
             "value":52}],
         "children":[]},
        {"id":"node229",
         "name":"2.29",
         "data":[
            {"key":"key1",
             "value":10},
            {"key":"key2",
             "value":-49}],
         "children":[]}]},
    {"id":"node130",
     "name":"1.30",
     "data":[
        {"key":"key1",
         "value":9},
        {"key":"key2",
         "value":-29}],
     "children":[
        {"id":"node231",
         "name":"2.31",
         "data":[
            {"key":"key1",
             "value":6},
            {"key":"key2",
             "value":-23}],
         "children":[]},
        {"id":"node232",
         "name":"2.32",
         "data":[
            {"key":"key1",
             "value":10},
            {"key":"key2",
             "value":19}],
         "children":[]},
        {"id":"node233",
         "name":"2.33",
         "data":[
            {"key":"key1",
             "value":1},
            {"key":"key2",
             "value":92}],
         "children":[]}]},
    {"id":"node134",
     "name":"1.34",
     "data":[
        {"key":"key1",
         "value":9},
        {"key":"key2",
         "value":71}],
     "children":[
        {"id":"node235",
         "name":"2.35",
         "data":[
            {"key":"key1",
             "value":5},
            {"key":"key2",
             "value":-65}],
         "children":[]}]},
    {"id":"node136",
     "name":"1.36",
     "data":[
        {"key":"key1",
         "value":3},
        {"key":"key2",
         "value":-11}],
     "children":[
        {"id":"node237",
         "name":"2.37",
         "data":[
            {"key":"key1",
             "value":6},
            {"key":"key2",
             "value":-85}],
         "children":[]},
        {"id":"node238",
         "name":"2.38",
         "data":[
            {"key":"key1",
             "value":3},
            {"key":"key2",
             "value":-13}],
         "children":[]},
        {"id":"node239",
         "name":"2.39",
         "data":[
            {"key":"key1",
             "value":1},
            {"key":"key2",
             "value":80}],
         "children":[]},
        {"id":"node240",
         "name":"2.40",
         "data":[
            {"key":"key1",
             "value":10},
            {"key":"key2",
             "value":-69}],
         "children":[]}]},
    {"id":"node141",
     "name":"1.41",
     "data":[
        {"key":"key1",
         "value":10},
        {"key":"key2",
         "value":-4}],
     "children":[
        {"id":"node242",
         "name":"2.42",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":-27}],
         "children":[]},
        {"id":"node243",
         "name":"2.43",
         "data":[
            {"key":"key1",
             "value":9},
            {"key":"key2",
             "value":-44}],
         "children":[]},
        {"id":"node244",
         "name":"2.44",
         "data":[
            {"key":"key1",
             "value":9},
            {"key":"key2",
             "value":24}],
         "children":[]},
        {"id":"node245",
         "name":"2.45",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":-66}],
         "children":[]}]}]};</pre>
</div>
<p>Put this HTML in your page:</p>
<pre name="code" class="html:nogutter:nocontrols">&lt;html&gt;
	&lt;head&gt;

	&lt;link type="text/css" rel="stylesheet" href="/static/css/example-rgraph.css" /&gt;

	&lt;!--[if IE]&gt;
		&lt;script type="text/javascript" src="/static/js/excanvas.js"&gt;&lt;/script&gt;
	&lt;![endif]--&gt;

	&lt;script type="text/javascript" src="/static/js/rgraph/RGraph.js" &gt;&lt;/script&gt;
	&lt;script type="text/javascript" src="/static/js/example/example-rgraph.js" &gt;&lt;/script&gt;

	&lt;/head&gt;
	&lt;body onload="init();"&gt;

         &lt;canvas id="infovis" width="900" height="500"&gt;&lt;/canvas&gt;
         &lt;div id="label_container"&gt;&lt;/div&gt;

	&lt;/body&gt;
&lt;/html&gt;</pre>
<p><strong>Note:</strong> You&#8217;ll probably have to change the paths to the css and javascript files.</p>
<p>Now, create a rgraph-example.css and put this code in it:</p>
<pre name="code" class="css:nogutter:nocontrols">html,body {
	width:100%;
	height:100%;
	overflow:hidden;
	margin:0;padding:0;
	background-color:#333;
	text-align:center;
}

#infovis {
	width:900px;
	height:500px;
	background-color:#222;
}

.node {
	color: white;
	background-color:transparent;
	cursor:pointer;
	font-weight:bold;
	opacity:0.9;
	border:1px solid red;
}

.node:hover {
	cursor:pointer;
	color: #222;
	background-color:white;
	font-weight:bold;
	opacity:1;
}</pre>
<p>Finally, create an example-rgraph.js file and put this code in it:</p>
<pre name="code" class="js:nogutter:nocontrols">function init() {
  var json= //data defined previously...
  //Create canvas instance with canvas id, fill and stroke colors.
  var canvas= new Canvas('infovis', '#ccddee', '#772277');
  var rgraph= new RGraph(canvas);
  //load graph from tree data.
  rgraph.loadTreeFromJSON(json);
  //compute positions
  rgraph.compute();
  //make first plot
  rgraph.plot();
}</pre>
<p>You should see a RGraph up and running. Click on the labels and the tree should move.</p>
<h4>Some notes:</h4>
<ul>
<li> It&#8217;s mandatory to put the <em>width</em> and <em>height</em> properties on the canvas html tag.<br />
You could set those properties dynamically, of course, but what I mean is that setting only width and height <em>style</em> properties (as with CSS) isn&#8217;t enough.</li>
<li> You could change the label container id by setting the <em>Config.labelContainer</em> property to whatever id you like. Be sure to set that property before making a Canvas instance.</li>
<li> The <em>Canvas</em> constructor takes 3 parameters: the canvas id, the fillStyle property and the strokeStyle property. If you don&#8217;t know what those properties are, take a look at <a href="http://developer.mozilla.org/en/docs/Canvas_tutorial:Applying_styles_and_colors" target="_blank">this</a> section from the canvas tutorial.</li>
<li> You can take off the concentric circles by setting <em>Config.drawConcentricCircles</em> to false. Just be sure you do that before making a canvas or RGraph instance.</li>
</ul>
<h4>Customizing the Graph</h4>
<p>Let&#8217;s add some labels!<br />
<strong>Note:</strong> I&#8217;ll be using the Mootools library to do this, just because I don&#8217;t want to spend time writing low level code that would make the code uglier. You can use any library you want (or none at all) though.</p>
<p>First, strip off the <em>border: 1px solid red;</em> line from the <em>.node</em> class in your CSS file.<br />
It should look like this:</p>
<pre name="code" class="css:nogutter:nocontrols">.node {
	color: white;
	background-color:transparent;
	cursor:pointer;
	font-weight:bold;
	opacity:0.9;
}</pre>
<p>Now we are going to add a javascript controller in order to put the name of the nodes into the labels. Since we only need to do this once, we&#8217;ll use the <em>onCreateLabel</em> method. If you don&#8217;t know what I&#8217;m talking about you should probably read the on controllers post first.</p>
<p>So the JavaScript file should look like this now:</p>
<pre name="code" class="js:nogutter:nocontrols">function init() {
  var json= //data defined previously...
  //Create canvas instance with canvas id, fill and stroke colors.
  var canvas= new Canvas('infovis', '#ccddee', '#772277');
  var rgraph= new RGraph(canvas);

  //Add a controller to assign the node's name to the created label.
  rgraph.controller =  {
  	onCreateLabel: function(domElement, node) {
  		domElement.innerHTML = node.name;
  	}
  };

  //load graph from tree data.
  rgraph.loadTreeFromJSON(json);
  //compute positions
  rgraph.compute();
  //make first plot
  rgraph.plot();
}</pre>
<p>You should see some labels now.<br />
The thing is that&#8230; well, they are not centered. So we&#8217;ll just add an onPlaceLabel method to the controller in order to do that, since the onPlaceLabel method is called after labels have been placed.</p>
<p>So the js code should now look like:</p>
<pre name="code" class="js:nogutter:nocontrols">function init() {
  var json= //json data...
  //Create canvas instance with canvas id, fill and stroke colors.
  var canvas= new Canvas('infovis', '#ccddee', '#772277');
  var rgraph= new RGraph(canvas);

  //Add a controller to assign the node's name to the created label.
  rgraph.controller =  {
  	onCreateLabel: function(domElement, node) {
  		domElement.innerHTML = node.name;
  	},

  	//Take off previous width and height styles and
  	//add half of the *actual* label width to the left position.
  	// That will center your label (do the math, man).
  	onPlaceLabel: function(domElement, node) {
		var left = parseInt(domElement.style.left);
		domElement.style.width = '';
		domElement.style.height = '';
		var w = domElement.offsetWidth;
		domElement.style.left = (left - w /2) + 'px';
	}

  };

  //load graph from tree data.
  rgraph.loadTreeFromJSON(json);
  //compute positions
  rgraph.compute();
  //make first plot
  rgraph.plot();
}</pre>
<p>You should see some centered labels now!</p>
<p>Labels already have the <em>onclick</em> event handler to move the graph.</p>
<p>Remember there are lots of other controller methods!</p>
<p>Remember also that you can change the animation time and the frames per second in the animation with <em>Config.animationTime</em> and <em>Config.fps</em>.<br />
Hope it was helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2008/05/07/rgraph-quick-tutorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>ST quick tutorial</title>
		<link>http://blog.thejit.org/2008/05/07/st-quick-tutorial/</link>
		<comments>http://blog.thejit.org/2008/05/07/st-quick-tutorial/#comments</comments>
		<pubDate>Wed, 07 May 2008 18:37:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>

		<category><![CDATA[information visualization]]></category>

		<category><![CDATA[JIT]]></category>

		<category><![CDATA[spacetree]]></category>

		<category><![CDATA[ST]]></category>

		<guid isPermaLink="false">http://blogngb.woot.com.ar/?p=11</guid>
		<description><![CDATA[This tutorial requires you to have read Feeding JSON tree structures to the JIT and on controllers first.
Hi, this is going to be a quick tutorial on how to set the ST up and running.
We are going to work with this tree JSON structure:

var json = {"id":"node02",
 "name":"0.2",
 "data":[
    {"key":"key1",
   [...]]]></description>
			<content:encoded><![CDATA[<p><em>This tutorial requires you to have read <a href="http://blog.thejit.org/?p=7">Feeding JSON tree structures to the JIT</a> and <a href="http://blog.thejit.org/?p=8">on controllers</a> first</em>.</p>
<p>Hi, this is going to be a quick tutorial on how to set the ST up and running.</p>
<p>We are going to work with this tree JSON structure:</p>
<div style="height:300px;overflow:scroll;">
<pre name="code" class="js:nogutter:nocontrols">var json = {"id":"node02",
 "name":"0.2",
 "data":[
    {"key":"key1",
     "value":2},
    {"key":"key2",
     "value":-86}],
 "children":[
    {"id":"node13",
     "name":"1.3",
     "data":[
        {"key":"key1",
         "value":7},
        {"key":"key2",
         "value":73}],
     "children":[
        {"id":"node24",
         "name":"2.4",
         "data":[
            {"key":"key1",
             "value":2},
            {"key":"key2",
             "value":-49}],
         "children":[
            {"id":"node35",
             "name":"3.5",
             "data":[
                {"key":"key1",
                 "value":8},
                {"key":"key2",
                 "value":-10}],
             "children":[
                {"id":"node46",
                 "name":"4.6",
                 "data":[
                    {"key":"key1",
                     "value":10},
                    {"key":"key2",
                     "value":74}],
                 "children":[]},
                {"id":"node47",
                 "name":"4.7",
                 "data":[
                    {"key":"key1",
                     "value":3},
                    {"key":"key2",
                     "value":-37}],
                 "children":[]}]},
            {"id":"node38",
             "name":"3.8",
             "data":[
                {"key":"key1",
                 "value":8},
                {"key":"key2",
                 "value":88}],
             "children":[
                {"id":"node49",
                 "name":"4.9",
                 "data":[
                    {"key":"key1",
                     "value":2},
                    {"key":"key2",
                     "value":-67}],
                 "children":[]},
                {"id":"node410",
                 "name":"4.10",
                 "data":[
                    {"key":"key1",
                     "value":10},
                    {"key":"key2",
                     "value":38}],
                 "children":[]},
                {"id":"node411",
                 "name":"4.11",
                 "data":[
                    {"key":"key1",
                     "value":5},
                    {"key":"key2",
                     "value":-77}],
                 "children":[]}]}]},
        {"id":"node212",
         "name":"2.12",
         "data":[
            {"key":"key1",
             "value":3},
            {"key":"key2",
             "value":-99}],
         "children":[
            {"id":"node313",
             "name":"3.13",
             "data":[
                {"key":"key1",
                 "value":9},
                {"key":"key2",
                 "value":48}],
             "children":[
                {"id":"node414",
                 "name":"4.14",
                 "data":[
                    {"key":"key1",
                     "value":8},
                    {"key":"key2",
                     "value":-19}],
                 "children":[]},
                {"id":"node415",
                 "name":"4.15",
                 "data":[
                    {"key":"key1",
                     "value":10},
                    {"key":"key2",
                     "value":61}],
                 "children":[]},
                {"id":"node416",
                 "name":"4.16",
                 "data":[
                    {"key":"key1",
                     "value":2},
                    {"key":"key2",
                     "value":83}],
                 "children":[]}]},
            {"id":"node317",
             "name":"3.17",
             "data":[
                {"key":"key1",
                 "value":4},
                {"key":"key2",
                 "value":-18}],
             "children":[
                {"id":"node418",
                 "name":"4.18",
                 "data":[
                    {"key":"key1",
                     "value":9},
                    {"key":"key2",
                     "value":-58}],
                 "children":[]},
                {"id":"node419",
                 "name":"4.19",
                 "data":[
                    {"key":"key1",
                     "value":6},
                    {"key":"key2",
                     "value":-35}],
                 "children":[]},
                {"id":"node420",
                 "name":"4.20",
                 "data":[
                    {"key":"key1",
                     "value":1},
                    {"key":"key2",
                     "value":84}],
                 "children":[]},
                {"id":"node421",
                 "name":"4.21",
                 "data":[
                    {"key":"key1",
                     "value":1},
                    {"key":"key2",
                     "value":19}],
                 "children":[]}]}]},
        {"id":"node222",
         "name":"2.22",
         "data":[
            {"key":"key1",
             "value":7},
            {"key":"key2",
             "value":-3}],
         "children":[
            {"id":"node323",
             "name":"3.23",
             "data":[
                {"key":"key1",
                 "value":9},
                {"key":"key2",
                 "value":-53}],
             "children":[
                {"id":"node424",
                 "name":"4.24",
                 "data":[
                    {"key":"key1",
                     "value":4},
                    {"key":"key2",
                     "value":63}],
                 "children":[]},
                {"id":"node425",
                 "name":"4.25",
                 "data":[
                    {"key":"key1",
                     "value":8},
                    {"key":"key2",
                     "value":38}],
                 "children":[]},
                {"id":"node426",
                 "name":"4.26",
                 "data":[
                    {"key":"key1",
                     "value":5},
                    {"key":"key2",
                     "value":84}],
                 "children":[]}]}]}]},
    {"id":"node127",
     "name":"1.27",
     "data":[
        {"key":"key1",
         "value":4},
        {"key":"key2",
         "value":34}],
     "children":[
        {"id":"node228",
         "name":"2.28",
         "data":[
            {"key":"key1",
             "value":6},
            {"key":"key2",
             "value":-8}],
         "children":[
            {"id":"node329",
             "name":"3.29",
             "data":[
                {"key":"key1",
                 "value":4},
                {"key":"key2",
                 "value":-48}],
             "children":[
                {"id":"node430",
                 "name":"4.30",
                 "data":[
                    {"key":"key1",
                     "value":3},
                    {"key":"key2",
                     "value":-64}],
                 "children":[]},
                {"id":"node431",
                 "name":"4.31",
                 "data":[
                    {"key":"key1",
                     "value":6},
                    {"key":"key2",
                     "value":-79}],
                 "children":[]},
                {"id":"node432",
                 "name":"4.32",
                 "data":[
                    {"key":"key1",
                     "value":2},
                    {"key":"key2",
                     "value":18}],
                 "children":[]}]},
            {"id":"node333",
             "name":"3.33",
             "data":[
                {"key":"key1",
                 "value":1},
                {"key":"key2",
                 "value":96}],
             "children":[
                {"id":"node434",
                 "name":"4.34",
                 "data":[
                    {"key":"key1",
                     "value":4},
                    {"key":"key2",
                     "value":32}],
                 "children":[]},
                {"id":"node435",
                 "name":"4.35",
                 "data":[
                    {"key":"key1",
                     "value":3},
                    {"key":"key2",
                     "value":-52}],
                 "children":[]}]},
            {"id":"node336",
             "name":"3.36",
             "data":[
                {"key":"key1",
                 "value":6},
                {"key":"key2",
                 "value":81}],
             "children":[
                {"id":"node437",
                 "name":"4.37",
                 "data":[
                    {"key":"key1",
                     "value":4},
                    {"key":"key2",
                     "value":-51}],
                 "children":[]},
                {"id":"node438",
                 "name":"4.38",
                 "data":[
                    {"key":"key1",
                     "value":9},
                    {"key":"key2",
                     "value":14}],
                 "children":[]},
                {"id":"node439",
                 "name":"4.39",
                 "data":[
                    {"key":"key1",
                     "value":8},
                    {"key":"key2",
                     "value":18}],
                 "children":[]},
                {"id":"node440",
                 "name":"4.40",
                 "data":[
                    {"key":"key1",
                     "value":7},
                    {"key":"key2",
                     "value":-3}],
                 "children":[]}]},
            {"id":"node341",
             "name":"3.41",
             "data":[
                {"key":"key1",
                 "value":9},
                {"key":"key2",
                 "value":-56}],
             "children":[
                {"id":"node442",
                 "name":"4.42",
                 "data":[
                    {"key":"key1",
                     "value":10},
                    {"key":"key2",
                     "value":56}],
                 "children":[]},
                {"id":"node443",
                 "name":"4.43",
                 "data":[
                    {"key":"key1",
                     "value":6},
                    {"key":"key2",
                     "value":-90}],
                 "children":[]},
                {"id":"node444",
                 "name":"4.44",
                 "data":[
                    {"key":"key1",
                     "value":10},
                    {"key":"key2",
                     "value":-64}],
                 "children":[]},
                {"id":"node445",
                 "name":"4.45",
                 "data":[
                    {"key":"key1",
                     "value":7},
                    {"key":"key2",
                     "value":-82}],
                 "children":[]}]}]},
        {"id":"node246",
         "name":"2.46",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":-16}],
         "children":[
            {"id":"node347",
             "name":"3.47",
             "data":[
                {"key":"key1",
                 "value":8},
                {"key":"key2",
                 "value":-41}],
             "children":[
                {"id":"node448",
                 "name":"4.48",
                 "data":[
                    {"key":"key1",
                     "value":7},
                    {"key":"key2",
                     "value":17}],
                 "children":[]},
                {"id":"node449",
                 "name":"4.49",
                 "data":[
                    {"key":"key1",
                     "value":7},
                    {"key":"key2",
                     "value":24}],
                 "children":[]},
                {"id":"node450",
                 "name":"4.50",
                 "data":[
                    {"key":"key1",
                     "value":6},
                    {"key":"key2",
                     "value":-11}],
                 "children":[]},
                {"id":"node451",
                 "name":"4.51",
                 "data":[
                    {"key":"key1",
                     "value":1},
                    {"key":"key2",
                     "value":-77}],
                 "children":[]}]},
            {"id":"node352",
             "name":"3.52",
             "data":[
                {"key":"key1",
                 "value":8},
                {"key":"key2",
                 "value":20}],
             "children":[
                {"id":"node453",
                 "name":"4.53",
                 "data":[
                    {"key":"key1",
                     "value":5},
                    {"key":"key2",
                     "value":20}],
                 "children":[]},
                {"id":"node454",
                 "name":"4.54",
                 "data":[
                    {"key":"key1",
                     "value":6},
                    {"key":"key2",
                     "value":77}],
                 "children":[]},
                {"id":"node455",
                 "name":"4.55",
                 "data":[
                    {"key":"key1",
                     "value":2},
                    {"key":"key2",
                     "value":52}],
                 "children":[]},
                {"id":"node456",
                 "name":"4.56",
                 "data":[
                    {"key":"key1",
                     "value":3},
                    {"key":"key2",
                     "value":41}],
                 "children":[]}]},
            {"id":"node357",
             "name":"3.57",
             "data":[
                {"key":"key1",
                 "value":2},
                {"key":"key2",
                 "value":-17}],
             "children":[
                {"id":"node458",
                 "name":"4.58",
                 "data":[
                    {"key":"key1",
                     "value":2},
                    {"key":"key2",
                     "value":4}],
                 "children":[]}]},
            {"id":"node359",
             "name":"3.59",
             "data":[
                {"key":"key1",
                 "value":10},
                {"key":"key2",
                 "value":-79}],
             "children":[
                {"id":"node460",
                 "name":"4.60",
                 "data":[
                    {"key":"key1",
                     "value":10},
                    {"key":"key2",
                     "value":-55}],
                 "children":[]},
                {"id":"node461",
                 "name":"4.61",
                 "data":[
                    {"key":"key1",
                     "value":4},
                    {"key":"key2",
                     "value":92}],
                 "children":[]},
                {"id":"node462",
                 "name":"4.62",
                 "data":[
                    {"key":"key1",
                     "value":10},
                    {"key":"key2",
                     "value":-40}],
                 "children":[]},
                {"id":"node463",
                 "name":"4.63",
                 "data":[
                    {"key":"key1",
                     "value":4},
                    {"key":"key2",
                     "value":57}],
                 "children":[]}]}]},
        {"id":"node264",
         "name":"2.64",
         "data":[
            {"key":"key1",
             "value":3},
            {"key":"key2",
             "value":91}],
         "children":[
            {"id":"node365",
             "name":"3.65",
             "data":[
                {"key":"key1",
                 "value":5},
                {"key":"key2",
                 "value":-51}],
             "children":[
                {"id":"node466",
                 "name":"4.66",
                 "data":[
                    {"key":"key1",
                     "value":6},
                    {"key":"key2",
                     "value":50}],
                 "children":[]},
                {"id":"node467",
                 "name":"4.67",
                 "data":[
                    {"key":"key1",
                     "value":2},
                    {"key":"key2",
                     "value":16}],
                 "children":[]}]},
            {"id":"node368",
             "name":"3.68",
             "data":[
                {"key":"key1",
                 "value":9},
                {"key":"key2",
                 "value":50}],
             "children":[
                {"id":"node469",
                 "name":"4.69",
                 "data":[
                    {"key":"key1",
                     "value":10},
                    {"key":"key2",
                     "value":-22}],
                 "children":[]},
                {"id":"node470",
                 "name":"4.70",
                 "data":[
                    {"key":"key1",
                     "value":5},
                    {"key":"key2",
                     "value":-71}],
                 "children":[]}]}]},
        {"id":"node271",
         "name":"2.71",
         "data":[
            {"key":"key1",
             "value":3},
            {"key":"key2",
             "value":-40}],
         "children":[
            {"id":"node372",
             "name":"3.72",
             "data":[
                {"key":"key1",
                 "value":7},
                {"key":"key2",
                 "value":-7}],
             "children":[
                {"id":"node473",
                 "name":"4.73",
                 "data":[
                    {"key":"key1",
                     "value":8},
                    {"key":"key2",
                     "value":-35}],
                 "children":[]},
                {"id":"node474",
                 "name":"4.74",
                 "data":[
                    {"key":"key1",
                     "value":8},
                    {"key":"key2",
                     "value":92}],
                 "children":[]},
                {"id":"node475",
                 "name":"4.75",
                 "data":[
                    {"key":"key1",
                     "value":2},
                    {"key":"key2",
                     "value":64}],
                 "children":[]},
                {"id":"node476",
                 "name":"4.76",
                 "data":[
                    {"key":"key1",
                     "value":7},
                    {"key":"key2",
                     "value":-95}],
                 "children":[]}]},
            {"id":"node377",
             "name":"3.77",
             "data":[
                {"key":"key1",
                 "value":3},
                {"key":"key2",
                 "value":-46}],
             "children":[
                {"id":"node478",
                 "name":"4.78",
                 "data":[
                    {"key":"key1",
                     "value":6},
                    {"key":"key2",
                     "value":56}],
                 "children":[]},
                {"id":"node479",
                 "name":"4.79",
                 "data":[
                    {"key":"key1",
                     "value":2},
                    {"key":"key2",
                     "value":-40}],
                 "children":[]},
                {"id":"node480",
                 "name":"4.80",
                 "data":[
                    {"key":"key1",
                     "value":2},
                    {"key":"key2",
                     "value":-88}],
                 "children":[]}]},
            {"id":"node381",
             "name":"3.81",
             "data":[
                {"key":"key1",
                 "value":6},
                {"key":"key2",
                 "value":-81}],
             "children":[
                {"id":"node482",
                 "name":"4.82",
                 "data":[
                    {"key":"key1",
                     "value":7},
                    {"key":"key2",
                     "value":-14}],
                 "children":[]}]},
            {"id":"node383",
             "name":"3.83",
             "data":[
                {"key":"key1",
                 "value":4},
                {"key":"key2",
                 "value":32}],
             "children":[
                {"id":"node484",
                 "name":"4.84",
                 "data":[
                    {"key":"key1",
                     "value":6},
                    {"key":"key2",
                     "value":36}],
                 "children":[]},
                {"id":"node485",
                 "name":"4.85",
                 "data":[
                    {"key":"key1",
                     "value":9},
                    {"key":"key2",
                     "value":96}],
                 "children":[]},
                {"id":"node486",
                 "name":"4.86",
                 "data":[
                    {"key":"key1",
                     "value":10},
                    {"key":"key2",
                     "value":13}],
                 "children":[]},
                {"id":"node487",
                 "name":"4.87",
                 "data":[
                    {"key":"key1",
                     "value":4},
                    {"key":"key2",
                     "value":96}],
                 "children":[]}]}]}]}]};</pre>
</div>
<p>Put this HTML in your page:</p>
<pre name="code" class="html:nogutter:nocontrols">&lt;html&gt;
	&lt;head&gt;

	&lt;link type="text/css" rel="stylesheet" href="/static/css/example-spacetree.css" /&gt;

	&lt;script type="text/javascript" src="/static/js/spacetree/Spacetree.js" &gt;&lt;/script&gt;
	&lt;script type="text/javascript" src="/static/js/example/example-spacetree.js" &gt;&lt;/script&gt;

	&lt;/head&gt;
	&lt;body onload="init();"&gt;

&lt;canvas id="infovis" width="900" height="500"&gt;&lt;/canvas&gt;
&lt;div id="label_container" /&gt;

	&lt;/body&gt;
&lt;/html&gt;</pre>
<p><strong>Note:</strong> You&#8217;ll probably have to change the paths to the css and javascript files.</p>
<p>Now, create a spacetree-example.css and put this code in it:</p>
<pre name="code" class="css:nogutter:nocontrols">html, body {
	width:100%;
	height:100%;
	background-color:#444;
	text-align:center;
	overflow:hidden;
	font-size:9px;
	font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;
	margin:0;padding:0;
}

#infovis {
	background-color:#222;
	position:relative;
	width:900px;
	height:500px;
}

a, a:link, a:visited {
	color:#343439;
}

.node {
	background-color:transparent;
	font-weight:bold;
	overflow:hidden;
	text-decoration:none;
	position:absolute;
	text-align:center;
	padding:4px 1px 1px 1px;
}

.node:hover {
	color:#393434;
}

.hidden{
	display:none;
}</pre>
<p><strong>Note:</strong> the <em>margin:0;padding:0;</em> on <em>html,body</em> is pretty important to place well the ST labels.</p>
<p>Finally, create an example-spacetree.js file and put this code in it:</p>
<pre name="code" class="js:nogutter:nocontrols">function init() {
  var json= //json data specified before...
  //Create a new canvas instance.
  var canvas= new Canvas('infovis');
  //Create a new ST instance
  var st= new ST(canvas);
  //load json data
  st.loadFromJSON(json);
  //compute node positions and layout
  st.compute();
  //optional: make a translation of the tree
  st.translate(st.tree, new Complex(200, 0), "pos");
  //Emulate a click on the root node.
  st.onClick(st.tree.id);
}</pre>
<p>You should see a spacetree up and running (it may take a few seconds to load).</p>
<h4>Some notes:</h4>
<ul>
<li> It&#8217;s mandatory to put the <em>width</em> and <em>height</em> properties on the canvas html tag.<br />
You could set those properties dynamically, of course, but what I mean is that setting only width and height <em>style</em> properties (as with CSS) isn&#8217;t enough.</li>
<li> You could change the label container id by setting the <em>Config.labelContainer</em> property to whatever id you like. Be sure to set that property before making a Canvas instance.</li>
<li> The <em>Canvas</em> constructor takes 1 parameter: the canvas id. To set the fillStyle and strokeStyle properties for nodes which are in path to root or nodes which aren&#8217;t you should refer to <em>Config.Node.(strokeStyle|fillStyle|strokeStyleInPath|fillStyleInPath)</em>.</li>
<li> You can define how many levels to expand by setting <em>Config.levelsToShow</em>. However, if the expanded subtree height is greater than the canvas height, the spacetree might not show all levels. Unfortunately, this doesn&#8217;t happen when the width of the subtree expanded is greater than the canvas width (divided by two).</li>
</ul>
<h4>Customizing the Spacetree</h4>
<p>The default layout for the spacetree is &#8220;left&#8221;. That means that the root node always lies at the left of the visualization. You can set the tree layout to &#8220;top&#8221; though.<br />
So, put a checkbox in your HTML. Your HTML should look like this:</p>
<pre name="code" class="html:nogutter:nocontrols">&lt;html&gt;
	&lt;head&gt;

	&lt;link type="text/css" rel="stylesheet" href="/static/css/example-spacetree.css" /&gt;

	&lt;script type="text/javascript" src="/static/js/spacetree/Spacetree.js" &gt;&lt;/script&gt;
	&lt;script type="text/javascript" src="/static/js/example/example-spacetree.js" &gt;&lt;/script&gt;

	&lt;/head&gt;
	&lt;body onload="init();"&gt;

&lt;input type="checkbox" id="switch"/&gt;
&lt;canvas id="infovis" width="900" height="500"&gt;&lt;/canvas&gt;
&lt;div id="label_container" /&gt;

	&lt;/body&gt;
&lt;/html&gt;</pre>
<p><strong>Note:</strong> You can add some style to the checkbox to put it somewhere else.</p>
<p>Now change the JS file to put a handler on the <em>onchange</em> event. It should look like this:</p>
<pre name="code" class="js:nogutter:nocontrols">function init() {
  var json= //json data specified before...
  //Create a new canvas instance.
  var canvas= new Canvas('infovis');
  //Create a new ST instance
  var st= new ST(canvas);
  //load json data
  st.loadFromJSON(json);
  //compute node positions and layout
  st.compute();
  //optional: make a translation of the tree
  st.translate(st.tree, new Complex(200, 0), "pos");
  //Emulate a click on the root node.
  st.onClick(st.tree.id);

  //Add input handler to switch spacetree orientation.
  var checkbox = document.getElementById('switch');
  checkbox.onchange = function () {
  	checkbox.disabled = true;
  	st.switchPosition({onComplete: function() {
  		checkbox.disabled = false;
  	}});
  };
}</pre>
<p>Now if you click on the checkbox you should be able to switch the Spacetree orientation. Hows that!</p>
<p>Remember that you can also add controlers to the spacetree!. Take a look at the on controllers section and some examples with the hypertree.</p>
<p>Hope it was helpful!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2008/05/07/st-quick-tutorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Treemap quick tutorial</title>
		<link>http://blog.thejit.org/2008/05/07/treemap-quick-tutorial/</link>
		<comments>http://blog.thejit.org/2008/05/07/treemap-quick-tutorial/#comments</comments>
		<pubDate>Wed, 07 May 2008 18:37:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>

		<category><![CDATA[information visualization]]></category>

		<category><![CDATA[JIT]]></category>

		<category><![CDATA[slice and dice]]></category>

		<category><![CDATA[squarified]]></category>

		<category><![CDATA[treemap]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blogngb.woot.com.ar/?p=10</guid>
		<description><![CDATA[This tutorial requires you to have read Feeding JSON tree structures to the JIT and on controllers first.
Hi, this is going to be a quick tutorial on how to set the treemap up and running.
Note: You could change all calls to TM.Squarified to TM.SliceAndDice and it should also work.
We are going to work with this [...]]]></description>
			<content:encoded><![CDATA[<p><em>This tutorial requires you to have read <a href="http://blog.thejit.org/?p=7">Feeding JSON tree structures to the JIT</a> and <a href="http://blog.thejit.org/?p=8">on controllers</a> first</em>.</p>
<p>Hi, this is going to be a quick tutorial on how to set the treemap up and running.</p>
<p><strong>Note:</strong> You could change all calls to <em>TM.Squarified</em> to <em>TM.SliceAndDice</em> and it should also work.</p>
<p>We are going to work with this tree JSON structure:</p>
<div style="height:300px;overflow:scroll;">
<pre name="code" class="js:nogutter:nocontrols">var json = {"id":"node02",
 "name":"0.2",
 "data":[
    {"key":"key1",
     "value":195},
    {"key":"key2",
     "value":5}],
 "children":[
    {"id":"node13",
     "name":"1.3",
     "data":[
        {"key":"key1",
         "value":23},
        {"key":"key2",
         "value":8}],
     "children":[
        {"id":"node24",
         "name":"2.4",
         "data":[
            {"key":"key1",
             "value":6},
            {"key":"key2",
             "value":-75}],
         "children":[]},
        {"id":"node25",
         "name":"2.5",
         "data":[
            {"key":"key1",
             "value":9},
            {"key":"key2",
             "value":-48}],
         "children":[]},
        {"id":"node26",
         "name":"2.6",
         "data":[
            {"key":"key1",
             "value":1},
            {"key":"key2",
             "value":-1}],
         "children":[]},
        {"id":"node27",
         "name":"2.7",
         "data":[
            {"key":"key1",
             "value":7},
            {"key":"key2",
             "value":25}],
         "children":[]}]},
    {"id":"node18",
     "name":"1.8",
     "data":[
        {"key":"key1",
         "value":17},
        {"key":"key2",
         "value":28}],
     "children":[
        {"id":"node29",
         "name":"2.9",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":-28}],
         "children":[]},
        {"id":"node210",
         "name":"2.10",
         "data":[
            {"key":"key1",
             "value":9},
            {"key":"key2",
             "value":-83}],
         "children":[]}]},
    {"id":"node111",
     "name":"1.11",
     "data":[
        {"key":"key1",
         "value":25},
        {"key":"key2",
         "value":-82}],
     "children":[
        {"id":"node212",
         "name":"2.12",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":-27}],
         "children":[]},
        {"id":"node213",
         "name":"2.13",
         "data":[
            {"key":"key1",
             "value":3},
            {"key":"key2",
             "value":-80}],
         "children":[]},
        {"id":"node214",
         "name":"2.14",
         "data":[
            {"key":"key1",
             "value":7},
            {"key":"key2",
             "value":-73}],
         "children":[]},
        {"id":"node215",
         "name":"2.15",
         "data":[
            {"key":"key1",
             "value":7},
            {"key":"key2",
             "value":26}],
         "children":[]}]},
    {"id":"node116",
     "name":"1.16",
     "data":[
        {"key":"key1",
         "value":17},
        {"key":"key2",
         "value":91}],
     "children":[
        {"id":"node217",
         "name":"2.17",
         "data":[
            {"key":"key1",
             "value":7},
            {"key":"key2",
             "value":48}],
         "children":[]},
        {"id":"node218",
         "name":"2.18",
         "data":[
            {"key":"key1",
             "value":10},
            {"key":"key2",
             "value":-86}],
         "children":[]}]},
    {"id":"node119",
     "name":"1.19",
     "data":[
        {"key":"key1",
         "value":52},
        {"key":"key2",
         "value":-77}],
     "children":[
        {"id":"node220",
         "name":"2.20",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":64}],
         "children":[]},
        {"id":"node221",
         "name":"2.21",
         "data":[
            {"key":"key1",
             "value":5},
            {"key":"key2",
             "value":84}],
         "children":[]},
        {"id":"node222",
         "name":"2.22",
         "data":[
            {"key":"key1",
             "value":6},
            {"key":"key2",
             "value":81}],
         "children":[]},
        {"id":"node223",
         "name":"2.23",
         "data":[
            {"key":"key1",
             "value":1},
            {"key":"key2",
             "value":25}],
         "children":[]},
        {"id":"node224",
         "name":"2.24",
         "data":[
            {"key":"key1",
             "value":4},
            {"key":"key2",
             "value":18}],
         "children":[]},
        {"id":"node225",
         "name":"2.25",
         "data":[
            {"key":"key1",
             "value":10},
            {"key":"key2",
             "value":37}],
         "children":[]},
        {"id":"node226",
         "name":"2.26",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":83}],
         "children":[]},
        {"id":"node227",
         "name":"2.27",
         "data":[
            {"key":"key1",
             "value":10},
            {"key":"key2",
             "value":-62}],
         "children":[]}]},
    {"id":"node128",
     "name":"1.28",
     "data":[
        {"key":"key1",
         "value":37},
        {"key":"key2",
         "value":-40}],
     "children":[
        {"id":"node229",
         "name":"2.29",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":-67}],
         "children":[]},
        {"id":"node230",
         "name":"2.30",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":46}],
         "children":[]},
        {"id":"node231",
         "name":"2.31",
         "data":[
            {"key":"key1",
             "value":4},
            {"key":"key2",
             "value":-99}],
         "children":[]},
        {"id":"node232",
         "name":"2.32",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":-38}],
         "children":[]},
        {"id":"node233",
         "name":"2.33",
         "data":[
            {"key":"key1",
             "value":1},
            {"key":"key2",
             "value":-3}],
         "children":[]},
        {"id":"node234",
         "name":"2.34",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":82}],
         "children":[]}]},
    {"id":"node135",
     "name":"1.35",
     "data":[
        {"key":"key1",
         "value":24},
        {"key":"key2",
         "value":63}],
     "children":[
        {"id":"node236",
         "name":"2.36",
         "data":[
            {"key":"key1",
             "value":10},
            {"key":"key2",
             "value":8}],
         "children":[]},
        {"id":"node237",
         "name":"2.37",
         "data":[
            {"key":"key1",
             "value":8},
            {"key":"key2",
             "value":63}],
         "children":[]},
        {"id":"node238",
         "name":"2.38",
         "data":[
            {"key":"key1",
             "value":6},
            {"key":"key2",
             "value":46}],
         "children":[]}]}]};</pre>
</div>
<p><strong>Note:</strong> remember that the Treemap takes the first <em>dataset</em> object value to calculate the rectangles dimension. That means that the values you setted on the first <em>dataset</em> object for all nodes must be <em>coherent</em>. <em>Coherent</em> means that, for example, if node <em>A</em> has nodes <em>B</em> and <em>C</em> as children, <em>B</em> having 3 as its first <em>dataset</em> object value and <em>C</em> having 2 as its first <em>dataset</em> value, then <em>A</em> must have 5 as its first <em>dataset</em> object value.</p>
<p>Put this HTML in your page:</p>
<pre name="code" class="html:nogutter:nocontrols">&lt;html&gt;
	&lt;head&gt;

	&lt;link type="text/css" rel="stylesheet" href="/static/css/example-treemap.css" /&gt;

	&lt;script type="text/javascript" src="/static/js/mootools-beta-1.2b2.js"&gt;&lt;/script&gt;
	&lt;script type="text/javascript" src="/static/js/treemap/Treemap.js" &gt;&lt;/script&gt;
	&lt;script type="text/javascript" src="/static/js/example/example-treemap.js" &gt;&lt;/script&gt;

	&lt;/head&gt;

	&lt;body onload="init();"&gt;

&lt;div id="infovis" /&gt;

	&lt;/body&gt;
&lt;/html&gt;</pre>
<p><strong>Note:</strong> You&#8217;ll probably have to change the paths to the css and javascript files.<br />
<strong>Note2:</strong> This is the only visualization that requires Mootools 1.2+ to run. I use version 1.2b2 and no, I haven&#8217;t tested it with Mootools 1.2b1, but I guess it should work. Download from <a href="http://mootools.net/download/tags/1-2b2" target="_blank">here</a></p>
<p>Now, create a treemap-example.css and put this code in it:</p>
<div style="height:300px;overflow:scroll;">
<pre name="code" class="css:nogutter:nocontrols">html, body {
	width:100%;
	height:100%;
	background-color:#222;
	text-align:center;
	overflow:hidden;
	font-size:10px;
	font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;
}

#infovis {
	position:relative;
	width:900px;
	height:500px;
	margin:auto;
	background-color:#1D1D20;
}

#infovis div {
	position:absolute;
	overflow:hidden;
}

#infovis .content {
	background-color:#333;
	border:0px solid #111;
}

#infovis .head {
	height:12px;
	color:white;
	background-color:#444;
}

#infovis .head.in-path {
	background-color:#655;
}

#infovis .body {
	background-color:black;
}

#infovis .leaf {
	color:white;
	background-color:#111;
	display:table-cell;
	vertical-align:middle;
}

#infovis .over-leaf {
	border:1px solid #9FD4FF;
}

#infovis .over-content {
	background-color: #9FD4FF;
}

#infovis .over-head { /* ...boy i'm funny */
	background-color:#A4D9FF;
	color:black;
}

/*TOOLTIPS*/
.tool-tip {
	color: #fff;
	width: 139px;
	z-index: 13000;
	background-color: black;
}

.tool-title {
	font-weight: bold;
	font-size: 11px;
	margin: 0;
	color: #9FD4FF;
	padding: 8px 8px 4px;
	background-color: black;
}

.tool-text {
	font-size: 11px;
	padding: 4px 8px 8px;
	background-color: black;
}</pre>
</div>
<p><strong>Note:</strong> I won&#8217;t explain all CSS classes, they are pretty much self explainable. However, you <strong>must</strong> put a <em>position:relative;</em> in the infovis container (the visualization container), just as specified on the CSS stylesheet.</p>
<p>Finally, create an example-treemap.js file and put this code in it:</p>
<pre name="code" class="js:nogutter:nocontrols">function init() {
	var json = //json data specified above...
	var tm = new TM.Squarified();
	tm.loadFromJSON(json);

}</pre>
<p>You should see a treemap up and running.</p>
<h4>Some notes:</h4>
<ul>
<li> It&#8217;s mandatory to put the <em>width</em> and <em>height</em> <em>style</em> properties on the main div container, just as specified on the CSS stylesheet.</li>
<li> You could change the main container id by setting the <em>Config.rootId</em> property to whatever id you like. Be sure to set that property before making a TM instance.</li>
</ul>
<h4>Customizing the Treemap</h4>
<p>Let&#8217;s add some colors!<br />
In order to add colors you must know three things:</p>
<ul>
<li> Colors are calculated by taking the second <em>dataset</em> object value. You must also know the range of this value. In this example the second value ranges between [-100, 100]. You can change these values by setting the <em>Config.Color.minValue</em> and <em>Config.Color.maxValue</em> parameters. Remember to do this before instanciating the TM.</li>
<li> You can also choose the color range for your visualization, this is done by setting the <em>Config.Color.minColorValue</em> and <em>Config.Color.maxColorValue</em> parameters. These properties take an array of 3 integers each describing an RGB value. Remember to do this before instanciating the TM.</li>
<li> Finally, to enable treemap coloring you must set the property <em>Config.Color.allow</em> to <em>true</em>.</li>
</ul>
<p>So the <em>init</em> javascript function would now look like:</p>
<pre name="code" class="js:nogutter:nocontrols">function init() {
	var json = //..json data
	//Allow coloring
	Config.Color.allow = true;
	//Set min value and max value for the second *dataset* object values.
	//Default's to -100 and 100.
	Config.Color.minValue = -100;
	Config.Color.maxValue = 100;
	//Set color range. Default's to reddish and greenish. It takes an array of three
	//integers as R, G and B values.
	Config.Color.minColorValue = [255, 0, 50];
	Config.Color.maxColorValue = [0, 255, 50];

	var tm = new TM.Squarified();
	tm.loadFromJSON(json);
}</pre>
<p>You should see a colored treemap now.</p>
<p>Finally, let&#8217;s put nice tooltips! We&#8217;ll do this by using the Tooltip Mootools class.<br />
First, we&#8217;ll define a controller to put the event handlers we need on element creation. The <em>element</em> is here the reactangle created.<br />
I also define some extra methods that convert the <em>dataset</em> to HTML.<br />
I also allow tooltips by setting <em>Config.tips</em> to true.</p>
<p>So the JavaScript file should now look like this:</p>
<pre name="code" class="js:nogutter:nocontrols">function init() {
	var json = //...same json data as before...
	//Allow coloring
	Config.Color.allow = true;
	//Set min value and max value for the second *dataset* object values.
	//Default's to -100 and 100.
	Config.Color.minValue = -100;
	Config.Color.maxValue = 100;
	//Set color range. Default's to reddish and greenish. It takes an array of three
	//integers as R, G and B values.
	Config.Color.minColorValue = [255, 0, 50];
	Config.Color.maxColorValue = [0, 255, 50];

	//Allow tips for treemap
	Config.tips = true;

	var tm = new TM.Squarified();
	//We define a controller to the treemap instance.
	tm.controller = {
		//The interface method to be called, treemap element creation.
		onCreateElement: function(domElement, node) {
			this.makeTip(domElement, node);
		},
		//Tooltip content is setted by setting the *title* of the element to be *tooltiped*.
		//Read the mootools docs for further understanding.
		makeTip: function(elem, json) {
			var title = json.name;
			var html = this.makeHTMLFromData(json.data);
			elem.set('title', title + '::' + html);
		},
		//Take each dataset object key and value and make an HTML from it.
		makeHTMLFromData: function(data) {
			var html = '';
			for(var i=0; i&lt;data.length; i++) {
				html += data[i].key + ': ' + data[i].value + '&lt;br /&gt;';
			}
			return html;
		}

	};

	tm.loadFromJSON(json);
}</pre>
<p>You should see some tooltips now!</p>
<p>Remember that you have more controller methods to customize your visualization just as you want! Hope it was helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2008/05/07/treemap-quick-tutorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hypertree quick tutorial</title>
		<link>http://blog.thejit.org/2008/05/07/hypertree-quick-tutorial/</link>
		<comments>http://blog.thejit.org/2008/05/07/hypertree-quick-tutorial/#comments</comments>
		<pubDate>Wed, 07 May 2008 18:37:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>

		<category><![CDATA[hyperbolic tree]]></category>

		<category><![CDATA[information visualization]]></category>

		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blogngb.woot.com.ar/?p=9</guid>
		<description><![CDATA[This tutorial requires you to have read Feeding JSON tree structures to the JIT and on controllers first.
Hi, this is going to be a quick tutorial on how to set the hyperbolic tree up and running.
We are going to work with this tree JSON structure:

var json = {"id":"node02",
"name":"0.2",
"data":[
{"key":"key1",
"value":9},
{"key":"key2",
"value":71}],
"children":[
{"id":"node13",
"name":"1.3",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":-9}],
"children":[
{"id":"node24",
"name":"2.4",
"data":[
{"key":"key1",
"value":3},
{"key":"key2",
"value":-42}],
"children":[]},
{"id":"node25",
"name":"2.5",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":59}],
"children":[]},
{"id":"node26",
"name":"2.6",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-50}],
"children":[]},
{"id":"node27",
"name":"2.7",
"data":[
{"key":"key1",
"value":3},
{"key":"key2",
"value":-78}],
"children":[]}]},
{"id":"node18",
"name":"1.8",
"data":[
{"key":"key1",
"value":1},
{"key":"key2",
"value":79}],
"children":[
{"id":"node29",
"name":"2.9",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":77}],
"children":[]},
{"id":"node210",
"name":"2.10",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":30}],
"children":[]},
{"id":"node211",
"name":"2.11",
"data":[
{"key":"key1",
"value":3},
{"key":"key2",
"value":-44}],
"children":[]}]},
{"id":"node112",
"name":"1.12",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":94}],
"children":[
{"id":"node213",
"name":"2.13",
"data":[
{"key":"key1",
"value":3},
{"key":"key2",
"value":99}],
"children":[]},
{"id":"node214",
"name":"2.14",
"data":[
{"key":"key1",
"value":4},
{"key":"key2",
"value":-72}],
"children":[]},
{"id":"node215",
"name":"2.15",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":17}],
"children":[]},
{"id":"node216",
"name":"2.16",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":53}],
"children":[]},
{"id":"node217",
"name":"2.17",
"data":[
{"key":"key1",
"value":4},
{"key":"key2",
"value":-96}],
"children":[]},
{"id":"node218",
"name":"2.18",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":-84}],
"children":[]},
{"id":"node219",
"name":"2.19",
"data":[
{"key":"key1",
"value":9},
{"key":"key2",
"value":-4}],
"children":[]},
{"id":"node220",
"name":"2.20",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":66}],
"children":[]}]},
{"id":"node121",
"name":"1.21",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":0}],
"children":[
{"id":"node222",
"name":"2.22",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":66}],
"children":[]},
{"id":"node223",
"name":"2.23",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":-78}],
"children":[]},
{"id":"node224",
"name":"2.24",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-91}],
"children":[]},
{"id":"node225",
"name":"2.25",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":-51}],
"children":[]},
{"id":"node226",
"name":"2.26",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":25}],
"children":[]},
{"id":"node227",
"name":"2.27",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":30}],
"children":[]},
{"id":"node228",
"name":"2.28",
"data":[
{"key":"key1",
"value":3},
{"key":"key2",
"value":-43}],
"children":[]}]},
{"id":"node129",
"name":"1.29",
"data":[
{"key":"key1",
"value":3},
{"key":"key2",
"value":-89}],
"children":[
{"id":"node230",
"name":"2.30",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":96}],
"children":[]},
{"id":"node231",
"name":"2.31",
"data":[
{"key":"key1",
"value":1},
{"key":"key2",
"value":-21}],
"children":[]},
{"id":"node232",
"name":"2.32",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":17}],
"children":[]},
{"id":"node233",
"name":"2.33",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":42}],
"children":[]}]},
{"id":"node134",
"name":"1.34",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":84}],
"children":[
{"id":"node235",
"name":"2.35",
"data":[
{"key":"key1",
"value":9},
{"key":"key2",
"value":-14}],
"children":[]},
{"id":"node236",
"name":"2.36",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":60}],
"children":[]},
{"id":"node237",
"name":"2.37",
"data":[
{"key":"key1",
"value":1},
{"key":"key2",
"value":-71}],
"children":[]}]},
{"id":"node138",
"name":"1.38",
"data":[
{"key":"key1",
"value":9},
{"key":"key2",
"value":-70}],
"children":[
{"id":"node239",
"name":"2.39",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":-69}],
"children":[]},
{"id":"node240",
"name":"2.40",
"data":[
{"key":"key1",
"value":4},
{"key":"key2",
"value":-31}],
"children":[]},
{"id":"node241",
"name":"2.41",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-5}],
"children":[]},
{"id":"node242",
"name":"2.42",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":62}],
"children":[]},
{"id":"node243",
"name":"2.43",
"data":[
{"key":"key1",
"value":9},
{"key":"key2",
"value":91}],
"children":[]}]},
{"id":"node144",
"name":"1.44",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":10}],
"children":[
{"id":"node245",
"name":"2.45",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":-2}],
"children":[]},
{"id":"node246",
"name":"2.46",
"data":[
{"key":"key1",
"value":1},
{"key":"key2",
"value":93}],
"children":[]},
{"id":"node247",
"name":"2.47",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":70}],
"children":[]},
{"id":"node248",
"name":"2.48",
"data":[
{"key":"key1",
"value":4},
{"key":"key2",
"value":-40}],
"children":[]}]},
{"id":"node149",
"name":"1.49",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":-58}],
"children":[
{"id":"node250",
"name":"2.50",
"data":[
{"key":"key1",
"value":4},
{"key":"key2",
"value":-41}],
"children":[]},
{"id":"node251",
"name":"2.51",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":-91}],
"children":[]},
{"id":"node252",
"name":"2.52",
"data":[
{"key":"key1",
"value":5},
{"key":"key2",
"value":-21}],
"children":[]},
{"id":"node253",
"name":"2.53",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-69}],
"children":[]},
{"id":"node254",
"name":"2.54",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":5}],
"children":[]},
{"id":"node255",
"name":"2.55",
"data":[
{"key":"key1",
"value":5},
{"key":"key2",
"value":-43}],
"children":[]},
{"id":"node256",
"name":"2.56",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":64}],
"children":[]},
{"id":"node257",
"name":"2.57",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":-60}],
"children":[]}]},
{"id":"node158",
"name":"1.58",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":-63}],
"children":[
{"id":"node259",
"name":"2.59",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":86}],
"children":[]},
{"id":"node260",
"name":"2.60",
"data":[
{"key":"key1",
"value":4},
{"key":"key2",
"value":13}],
"children":[]},
{"id":"node261",
"name":"2.61",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-70}],
"children":[]},
{"id":"node262",
"name":"2.62",
"data":[
{"key":"key1",
"value":5},
{"key":"key2",
"value":-83}],
"children":[]},
{"id":"node263",
"name":"2.63",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-98}],
"children":[]},
{"id":"node264",
"name":"2.64",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-79}],
"children":[]},
{"id":"node265",
"name":"2.65",
"data":[
{"key":"key1",
"value":9},
{"key":"key2",
"value":10}],
"children":[]},
{"id":"node266",
"name":"2.66",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":17}],
"children":[]},
{"id":"node267",
"name":"2.67",
"data":[
{"key":"key1",
"value":8},
{"key":"key2",
"value":26}],
"children":[]}]}]};

Put this HTML in your page:
&#60;html&#62;
&#60;head&#62;

&#60;link type="text/css" rel="stylesheet" [...]]]></description>
			<content:encoded><![CDATA[<p><em>This tutorial requires you to have read <a href="http://blog.thejit.org/?p=7">Feeding JSON tree structures to the JIT</a> and <a href="http://blog.thejit.org/?p=8">on controllers</a> first</em>.</p>
<p>Hi, this is going to be a quick tutorial on how to set the hyperbolic tree up and running.</p>
<p>We are going to work with this tree JSON structure:</p>
<div style="height:300px;overflow:scroll;">
<pre name="code" class="js:nogutter:nocontrols">var json = {"id":"node02",
"name":"0.2",
"data":[
{"key":"key1",
"value":9},
{"key":"key2",
"value":71}],
"children":[
{"id":"node13",
"name":"1.3",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":-9}],
"children":[
{"id":"node24",
"name":"2.4",
"data":[
{"key":"key1",
"value":3},
{"key":"key2",
"value":-42}],
"children":[]},
{"id":"node25",
"name":"2.5",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":59}],
"children":[]},
{"id":"node26",
"name":"2.6",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-50}],
"children":[]},
{"id":"node27",
"name":"2.7",
"data":[
{"key":"key1",
"value":3},
{"key":"key2",
"value":-78}],
"children":[]}]},
{"id":"node18",
"name":"1.8",
"data":[
{"key":"key1",
"value":1},
{"key":"key2",
"value":79}],
"children":[
{"id":"node29",
"name":"2.9",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":77}],
"children":[]},
{"id":"node210",
"name":"2.10",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":30}],
"children":[]},
{"id":"node211",
"name":"2.11",
"data":[
{"key":"key1",
"value":3},
{"key":"key2",
"value":-44}],
"children":[]}]},
{"id":"node112",
"name":"1.12",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":94}],
"children":[
{"id":"node213",
"name":"2.13",
"data":[
{"key":"key1",
"value":3},
{"key":"key2",
"value":99}],
"children":[]},
{"id":"node214",
"name":"2.14",
"data":[
{"key":"key1",
"value":4},
{"key":"key2",
"value":-72}],
"children":[]},
{"id":"node215",
"name":"2.15",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":17}],
"children":[]},
{"id":"node216",
"name":"2.16",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":53}],
"children":[]},
{"id":"node217",
"name":"2.17",
"data":[
{"key":"key1",
"value":4},
{"key":"key2",
"value":-96}],
"children":[]},
{"id":"node218",
"name":"2.18",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":-84}],
"children":[]},
{"id":"node219",
"name":"2.19",
"data":[
{"key":"key1",
"value":9},
{"key":"key2",
"value":-4}],
"children":[]},
{"id":"node220",
"name":"2.20",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":66}],
"children":[]}]},
{"id":"node121",
"name":"1.21",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":0}],
"children":[
{"id":"node222",
"name":"2.22",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":66}],
"children":[]},
{"id":"node223",
"name":"2.23",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":-78}],
"children":[]},
{"id":"node224",
"name":"2.24",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-91}],
"children":[]},
{"id":"node225",
"name":"2.25",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":-51}],
"children":[]},
{"id":"node226",
"name":"2.26",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":25}],
"children":[]},
{"id":"node227",
"name":"2.27",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":30}],
"children":[]},
{"id":"node228",
"name":"2.28",
"data":[
{"key":"key1",
"value":3},
{"key":"key2",
"value":-43}],
"children":[]}]},
{"id":"node129",
"name":"1.29",
"data":[
{"key":"key1",
"value":3},
{"key":"key2",
"value":-89}],
"children":[
{"id":"node230",
"name":"2.30",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":96}],
"children":[]},
{"id":"node231",
"name":"2.31",
"data":[
{"key":"key1",
"value":1},
{"key":"key2",
"value":-21}],
"children":[]},
{"id":"node232",
"name":"2.32",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":17}],
"children":[]},
{"id":"node233",
"name":"2.33",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":42}],
"children":[]}]},
{"id":"node134",
"name":"1.34",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":84}],
"children":[
{"id":"node235",
"name":"2.35",
"data":[
{"key":"key1",
"value":9},
{"key":"key2",
"value":-14}],
"children":[]},
{"id":"node236",
"name":"2.36",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":60}],
"children":[]},
{"id":"node237",
"name":"2.37",
"data":[
{"key":"key1",
"value":1},
{"key":"key2",
"value":-71}],
"children":[]}]},
{"id":"node138",
"name":"1.38",
"data":[
{"key":"key1",
"value":9},
{"key":"key2",
"value":-70}],
"children":[
{"id":"node239",
"name":"2.39",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":-69}],
"children":[]},
{"id":"node240",
"name":"2.40",
"data":[
{"key":"key1",
"value":4},
{"key":"key2",
"value":-31}],
"children":[]},
{"id":"node241",
"name":"2.41",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-5}],
"children":[]},
{"id":"node242",
"name":"2.42",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":62}],
"children":[]},
{"id":"node243",
"name":"2.43",
"data":[
{"key":"key1",
"value":9},
{"key":"key2",
"value":91}],
"children":[]}]},
{"id":"node144",
"name":"1.44",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":10}],
"children":[
{"id":"node245",
"name":"2.45",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":-2}],
"children":[]},
{"id":"node246",
"name":"2.46",
"data":[
{"key":"key1",
"value":1},
{"key":"key2",
"value":93}],
"children":[]},
{"id":"node247",
"name":"2.47",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":70}],
"children":[]},
{"id":"node248",
"name":"2.48",
"data":[
{"key":"key1",
"value":4},
{"key":"key2",
"value":-40}],
"children":[]}]},
{"id":"node149",
"name":"1.49",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":-58}],
"children":[
{"id":"node250",
"name":"2.50",
"data":[
{"key":"key1",
"value":4},
{"key":"key2",
"value":-41}],
"children":[]},
{"id":"node251",
"name":"2.51",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":-91}],
"children":[]},
{"id":"node252",
"name":"2.52",
"data":[
{"key":"key1",
"value":5},
{"key":"key2",
"value":-21}],
"children":[]},
{"id":"node253",
"name":"2.53",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-69}],
"children":[]},
{"id":"node254",
"name":"2.54",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":5}],
"children":[]},
{"id":"node255",
"name":"2.55",
"data":[
{"key":"key1",
"value":5},
{"key":"key2",
"value":-43}],
"children":[]},
{"id":"node256",
"name":"2.56",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":64}],
"children":[]},
{"id":"node257",
"name":"2.57",
"data":[
{"key":"key1",
"value":10},
{"key":"key2",
"value":-60}],
"children":[]}]},
{"id":"node158",
"name":"1.58",
"data":[
{"key":"key1",
"value":7},
{"key":"key2",
"value":-63}],
"children":[
{"id":"node259",
"name":"2.59",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":86}],
"children":[]},
{"id":"node260",
"name":"2.60",
"data":[
{"key":"key1",
"value":4},
{"key":"key2",
"value":13}],
"children":[]},
{"id":"node261",
"name":"2.61",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-70}],
"children":[]},
{"id":"node262",
"name":"2.62",
"data":[
{"key":"key1",
"value":5},
{"key":"key2",
"value":-83}],
"children":[]},
{"id":"node263",
"name":"2.63",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-98}],
"children":[]},
{"id":"node264",
"name":"2.64",
"data":[
{"key":"key1",
"value":2},
{"key":"key2",
"value":-79}],
"children":[]},
{"id":"node265",
"name":"2.65",
"data":[
{"key":"key1",
"value":9},
{"key":"key2",
"value":10}],
"children":[]},
{"id":"node266",
"name":"2.66",
"data":[
{"key":"key1",
"value":6},
{"key":"key2",
"value":17}],
"children":[]},
{"id":"node267",
"name":"2.67",
"data":[
{"key":"key1",
"value":8},
{"key":"key2",
"value":26}],
"children":[]}]}]};</pre>
</div>
<p>Put this HTML in your page:</p>
<pre name="code" class="html:nogutter:nocontrols">&lt;html&gt;
&lt;head&gt;

&lt;link type="text/css" rel="stylesheet" href="/static/css/example-hypertree.css" /&gt;

&lt;!--[if IE]&gt;
&lt;script type="text/javascript" src="/static/js/excanvas.js"&gt;&lt;/script&gt;
&lt;![endif]--&gt;

&lt;script type="text/javascript" src="/static/js/hypertree/Hypertree.js" &gt;&lt;/script&gt;
&lt;script type="text/javascript" src="/static/js/example/example-hypertree.js" &gt;&lt;/script&gt;

&lt;/head&gt;
&lt;body onload="init();"&gt;

&lt;canvas id="infovis" width="900" height="500"&gt;&lt;/canvas&gt;
&lt;div id="label_container"&gt;&lt;/div&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
<p><strong>Note:</strong> You&#8217;ll probably have to change the paths to the css and javascript files.</p>
<p>Now, create a hypertree-example.css and put this code in it:</p>
<pre name="code" class="css:nogutter:nocontrols">html, body {
width:100%;
height:100%;
background-color:#444;
text-align:center;
overflow:hidden;
font-size:10px;
font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;

}

#infovis {
background-color:#222;
width:900px;
height:500px;
}

.node {
border: 1px solid #555;
background-color: #ccc;
color:#222;
cursor:pointer;
padding:2px;
display:none;
}

.hidden {
display:none;
}</pre>
<p><strong>Note:</strong> I like the canvas black, just like my coffee.</p>
<p>Finally, create an example-hypertree.js file and put this code in it:</p>
<pre name="code" class="js:nogutter:nocontrols">function init() {

var json = //the json structure mentioned above...
//Create a new canvas instance.
var canvas= new Canvas('infovis', '#fff', '#fff');
//create a new hypertree instance.
var ht= new Hypertree(canvas);
//feed the hypertree with a JSON structure.
ht.loadTreeFromJSON(json);
//compute node positions
ht.compute();
//plot the hypertree on canvas
ht.plot();
//add event handlers to the canvas in order to move the hypertree when I click con the canvas -optional-
ht.prepareCanvasEvents();
}</pre>
<p>You should see a hypertree up and running (it may take a few seconds to load).</p>
<h4>Some notes:</h4>
<ul>
<li> It&#8217;s mandatory to put the <em>width</em> and <em>height</em> properties on the canvas html tag.<br />
You could set those properties dynamically, of course, but what I mean is that setting only width and height <em>style</em> properties (as with CSS) isn&#8217;t enough.</li>
<li> You could change the label container id by setting the <em>Config.labelContainer</em> property to whatever id you like. Be sure to set that property before making a Canvas instance.</li>
<li> The <em>Canvas</em> constructor takes 3 parameters: the canvas id, the fillStyle property and the strokeStyle property. If you don&#8217;t know what those properties are, take a look at <a href="http://developer.mozilla.org/en/docs/Canvas_tutorial:Applying_styles_and_colors" target="_blank">this</a> section from the canvas tutorial.</li>
<li> It&#8217;s not mandatory to add the <em>ht.prepareCanvasEvents();</em> method. This method just adds some event handlers to the canvas tag in order to move the tree when you click on the canvas.</li>
<li> You can take off the main circle by setting <em>Config.drawMainCircle</em> to false. Just be sure you do that before making a canvas or Hypertree instance.</li>
</ul>
<h4>Customizing the Hypertree</h4>
<p>Let&#8217;s add some labels!<br />
<strong>Note:</strong> I&#8217;ll be using the Mootools library to do this, just because I don&#8217;t want to spend time writing low level code that would make the code uglier. You can use any library you want (or none at all) though.</p>
<p>First, strip off the <em>display:none;</em> line from the <em>.node</em> class in your CSS file.<br />
It should look like this:</p>
<pre name="code" class="css:nogutter:nocontrols">.node {
border: 1px solid #555;
background-color: #ccc;
color:#222;
cursor:pointer;
padding:2px;
}</pre>
<p>Now we are going to add a javascript controller in order to put the name of the nodes into the labels. Since we only need to do this once, we&#8217;ll use the <em>onCreateLabel</em> method. If you don&#8217;t know what I&#8217;m talking about you should probably read the on controllers post first.</p>
<p>So the JavaScript file should look like this now:</p>
<pre name="code" class="js:nogutter:nocontrols">function init() {

var json = //json data mentioned above...
var canvas= new Canvas('infovis', '#fff', '#fff');
var ht= new Hypertree(canvas);

//Add a controller to assign the node's name to the created label.
ht.controller = {
onCreateLabel: function(domElement, node) {
$(domElement).setHTML(node.name + " and text");
}
};

ht.loadTreeFromJSON(json);
ht.compute();
ht.plot();
ht.prepareCanvasEvents();
}</pre>
<p>You should see some labels now.<br />
The thing is that&#8230; well, they are not centered. So we&#8217;ll just add an onPlaceLabel method to the controller in order to do that, since the onPlaceLabel method is called after labels have been placed.</p>
<p>So the js code should now look like:</p>
<pre name="code" class="js:nogutter:nocontrols">function init() {

var json = //json data...
var canvas= new Canvas('infovis', '#fff', '#fff');
var ht= new Hypertree(canvas);

//Add a controller to assign the node's name to the created label.
ht.controller = {
onCreateLabel: function(domElement, node) {
$(domElement).setHTML(node.name + " and text");
},

//Take the left style property and substract half of the label actual width.
onPlaceLabel: function(tag, node) {
var width = tag.offsetWidth;
var intX = tag.style.left.toInt();
intX -= width/2;
tag.style.left = intX + 'px';
}

};

ht.loadTreeFromJSON(json);
ht.compute();
ht.plot();
ht.prepareCanvasEvents();
}</pre>
<p>You should see some centered labels now!</p>
<p>Finally, we&#8217;ll add an <em>onclick</em> event handler in order to move the tree when clicking on a label, hows that!</p>
<p>We&#8217;ll add this method on the onCreateLabel method, just because we only want to add label event handlers once.<br />
So the code should look like:</p>
<pre name="code" class="js:nogutter:nocontrols">function init() {

var json = //some json data
var canvas= new Canvas('infovis', '#fff', '#fff');
var ht= new Hypertree(canvas);

//Add a controller to assign the node's name to the created label.
ht.controller = {
onCreateLabel: function(domElement, node) {
$(domElement).setHTML(node.name + " and text").addEvents({

//Call the "onclick" method from the hypertree to move the hypertree correspondingly.
//This method takes the native event object. Since Mootools uses a wrapper for this
//event, I have to put e.event to get the native event object.
'click': function(e) {
ht.onClick(e.event);
}
});

},

//Take the left style property and substract half of the label actual width.
onPlaceLabel: function(tag, node) {
var width = tag.offsetWidth;
var intX = tag.style.left.toInt();
intX -= width/2;
tag.style.left = intX + 'px';
}

};

ht.loadTreeFromJSON(json);
ht.compute();
ht.plot();
ht.prepareCanvasEvents();
}</pre>
<p>Remember that you have more controller methods!<br />
Remember also that you can change the animation time and the frames per second in the animation with <em>Config.animationTime</em> and <em>Config.fps</em>.<br />
Hope it was helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2008/05/07/hypertree-quick-tutorial/feed/</wfw:commentRss>
		</item>
		<item>
		<title>On controllers</title>
		<link>http://blog.thejit.org/2008/04/27/on-controllers/</link>
		<comments>http://blog.thejit.org/2008/04/27/on-controllers/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 02:11:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>

		<category><![CDATA[controller]]></category>

		<category><![CDATA[information visualization]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[JIT]]></category>

		<guid isPermaLink="false">http://blogngb.woot.com.ar/?p=8</guid>
		<description><![CDATA[Controllers are a straightforward way to customize the JavaScript infovis toolkit (JIT) visualizations.
 A controller is a JavaScript object that &#8220;implements&#8221; an interface. The interface methods will then be called at different stages of the visualization, allowing you to, for example, place labels and add event handlers to them, performing actions before and after the [...]]]></description>
			<content:encoded><![CDATA[<p>Controllers are a straightforward way to customize the JavaScript infovis toolkit (JIT) visualizations.<br />
 A controller is a JavaScript object that &#8220;implements&#8221; an interface. The interface methods will then be called at different stages of the visualization, allowing you to, for example, place labels and add event handlers to them, performing actions before and after the animation, making ajax - calls to load data dynamically to the tree, etc.</p>
<p>The controller interface is defined as:</p>
<pre name="code" class="js:nogutter:nocontrols">
 var ControllerInterface = {

       onCreateLabel: function (domElement, node) {},

       onPlaceLabel: function (domElement, node) {},

       onCreateElement: function(domElement, node) {},

       onBeforeCompute: function (node) {},

       onAfterCompute: function () {}

       request: function(nodeId, level, onComplete) {},

 };
 </pre>
<p>where:</p>
<ul>
<li><b>onCreateLabel(domElement, node)</b> is a method that receives the label dom element as first parameter, and the homologue JSON tree node as second parameter. This method will only be called on label creation. Note that a JSON tree node is a node from the input tree you provided to the visualization. If you don&#8217;t know what kind of JSON tree format is used to feed the visualizations, you should take a look at my other post first, <a href="/?p=7">feeding JSON tree structures to the JIT</a>.<br />
This method proves useful when adding events to the labels used by the JIT. You should be carefull when adding events though, because some visualizations use the <em>onclick</em> event to add actions. For example, the Spacetree, RGraph and Hypertree visualizations add animation handlers on the <em>onclick</em> event for the labels.
 </li>
<li><b>onPlaceLabel(domElement, node)</b> is a method that receives the label dom element as first parameter and the homologue JSON tree node as second parameter. This method is called each time a label has been placed on the visualization, and thus it allows you to update the labels properties, such as size or position. Note that <em>onPlaceLabel</em> will be triggered after updating positions to the labels. That means that, for example, the <em>left</em> and <em>top</em> css properties are allready updated to match the nodes positions.
<li><b>onCreateElement(domElement, node)</b> is a method only used by the Treemap visualization. This method is called after a div container for a treemap node has been created. The <em>domElement</em> parameter is the actual div dom element being laid out. So, if you just wanted to add node names to each node div representation, you could just write
<pre name="code" class="js:nogutter:nocontrols">
onCreateElement: function(domElement, node) {
   domElement.innerHTML = node.name;
}
</pre>
</li>
<li><b>onBeforeCompute(node)</b> is a method called right before performing all computation and animations to the JIT visualization. In the case of treemaps this method will be called after entering or exiting a tree level. In the case of Hyperbolic trees, RGraphs and Spacetrees, this method will be triggered right before perfoming an animation.<br />
For Treemap visualizations, the <em>node</em> parameter corresponds to the root node of the subtree which will be laid out.<br />
For the Spacetree, Hypertree and RGraph visualizations, the <em>node</em> parameter corresponds to the actual node being clicked or centered on the canvas.
</li>
<li><b>onAfterCompute()</b> is a method triggered right after all animations or computations for the JIT visualizations ended.
</li>
<li><b>request(nodeId, level, onComplete)</b> is a method only used by the Treemap and Spacetree visualizations. You can use this method to &#8220;bufferize&#8221; information, so that not all the JSON tree structure is loaded at once. The <em>nodeId</em> parameter is the node actually being requested, the <em>level</em> parameter is the level of the subtree being requested, and the onComplete handler is a function you <b>must</b> call after performing your request. A common structure for the <em>request</em> method could be
<pre name="code" class="js:nogutter:nocontrols">
	request: function(nodeId, level, onComplete) {
		var data;
                //make a request call to fill the data object and on complete do:
		onComplete(nodeId, data);
	},
</pre>
</li>
</ul>
<p>Note that you should not declare any of these methods on your controller object if you are not going to use them.<br />
Note also that is not mandatory to provide a controller object to the main classes.<br />
You can find some example uses for the controller object at the spacetree, hypertree, treemap and rgraph tutorials.<br />
Be sure to know what JSON structure feeds the JIT visualizations before you read the tutorials.<br />
Hope it was helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2008/04/27/on-controllers/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Feeding JSON tree structures to the JIT</title>
		<link>http://blog.thejit.org/2008/04/27/feeding-json-tree-structures-to-the-jit/</link>
		<comments>http://blog.thejit.org/2008/04/27/feeding-json-tree-structures-to-the-jit/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 02:06:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>

		<category><![CDATA[information visualization]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[JIT]]></category>

		<category><![CDATA[JSON]]></category>

		<guid isPermaLink="false">http://blogngb.woot.com.ar/?p=7</guid>
		<description><![CDATA[The tree structure that feeds the spacetree, hypertree, treemap and rgraph visualizations is always the same.
Roughly speaking, the JSON tree structure consists of tree nodes, each having as properties:

id a unique identifier for the node.
name a node&#8217;s name.
data The data property contains a dataset. That is, an array of key-value objects defined by the user. [...]]]></description>
			<content:encoded><![CDATA[<p>The tree structure that feeds the spacetree, hypertree, treemap and rgraph visualizations is always the same.<br />
Roughly speaking, the JSON tree structure consists of tree nodes, each having as properties:</p>
<ul>
<li><b>id</b> a <b>unique</b> identifier for the node.</li>
<li><b>name</b> a node&#8217;s name.</li>
<li><b>data</b> The data property contains a <em>dataset</em>. That is, an array of key-value objects defined by the user. Roughly speaking, this is where you can put some extra information about your node. You&#8217;ll be able to access this information at different stages of the computation of the JIT visualizations by using a controller.
</li>
<li><b>children</b> An array of children nodes, or an empty array if the node is a leaf node.
</ul>
<p>For example,</p>
<pre name="code" class="js:nogutter:nocontrols">
var json = {
	"id": "aUniqueIdentifier",
	"name": "usually a nodes name",
	"data": [
	    {key:"some key",       value: "some value"},
		{key:"some other key", value: "some other value"}
	],
	children: [/* other nodes or empty */]
};
</pre>
<h3>About datasets:</h3>
<p>Sometimes some <em>dataset</em> objects are read by the JIT classes to perform proper layouts.<br />
For example, the treemap class reads the first object&#8217;s value for each node&#8217;s <em>dataset</em> to perform calculations about the dimensions of the rectangles laid.<br />
Also, if you enable the <em>Config.Color.allow</em> property, the treemap will add colors on the layout, and these colors will be based on your second <em>dataset</em> object value.<br />
Although it&#8217;s not implemented yet, RGraphs will also read the first <em>dataset</em> object value in order to compute node diameters and angular widths.</p>
<p>That&#8217;s all for now. I recommend you to read the <a href="/?p=8">On controllers</a> section and then some spacetree, hypertree, treemap or RGraph tutorials.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2008/04/27/feeding-json-tree-structures-to-the-jit/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
