<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Overfloater</title>
	
	<link>http://blog.thejit.org</link>
	<description>Data Visualization, JavaScript and Computer Science related stuff</description>
	<lastBuildDate>Sat, 04 Sep 2010 15:20:46 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Noumena" /><feedburner:info uri="noumena" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Three ways to make 3D</title>
		<link>http://feedproxy.google.com/~r/Noumena/~3/1GtuuyYtNXw/</link>
		<comments>http://blog.thejit.org/2010/09/04/three-ways-to-make-3d/#comments</comments>
		<pubDate>Sat, 04 Sep 2010 15:20:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Scala]]></category>
		<category><![CDATA[WebGL]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[visualization]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[spde]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=1580</guid>
		<description><![CDATA[Last week I got the chance to put my hands on some technologies I&#8217;ve been interested for some time now. I&#8217;ve created a basic 3D example of some fractals, and implemented it in 2D Canvas, WebGL and SPDE (Scala + Processing). 
The main goal of these experiments was to warm up a little bit in [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I got the chance to put my hands on some technologies I&#8217;ve been interested for some time now. I&#8217;ve created a basic 3D example of some fractals, and implemented it in <a href="https://developer.mozilla.org/en/Canvas_tutorial">2D Canvas</a>, <a href="http://en.wikipedia.org/wiki/WebGL">WebGL</a> and <a href="http://technically.us/spde/About">SPDE</a> (<a href="http://www.scala-lang.org/">Scala</a> + <a href="http://processing.org/">Processing</a>). </p>
<p>The main goal of these experiments was to warm up a little bit in 3D, to learn WebGL, Scala and Processing. I had previous experience with 3D and OpenGL while developing <a href="http://github.com/philogb/v8-gl#readme">V8-GL, an OpenGL ES port to V8</a>, and also while developing the <a href="http://blog.thejit.org/2008/12/06/using-ocaml-to-visualize-radioheads-hoc-music-video-part-3/">House of Cards visualization in OCaml</a>. But these were other times. Now <a href="http://flyingfrogblog.blogspot.com/2010/08/rise-and-fall-of-ocaml.html">OCaml is dead</a>, and there&#8217;s a <a href="http://www.khronos.org/webgl/">V8-GL port in the browser, which is called WebGL</a>. I&#8217;m kind of proud to have chosen things that became sort of mainstream later on though: functional programming for graphics and hardware accelerated graphics with JavaScript <img src='http://blog.thejit.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  .</p>
<h4>2D Canvas</h4>
<p>The 2D Canvas API has a limited capability for 3D graphics. In order to make 3D with it you can use some high level 3D engine like <a href="http://deanm.github.com/pre3d/">pre3d</a> or <a href="http://github.com/mrdoob/three.js">three.js</a> which provide classes to do mathy stuff in 3D and then use tricks like <a href="http://en.wikipedia.org/wiki/Pinhole_camera">the pinhole camera model</a> to project them on 2D. What&#8217;s interesting about three.js is that it also provides SVG and WebGL renderers. These are awesome tools to make 3D, but since my example was more in the spirit of the <a href="http://js1k.com/demos">JS1k demos</a> I decided to start from scratch. The only thing I used was the <a href="http://github.com/mrdoob/three.js/blob/master/src/core/Vector3.js">Vector3</a> and <a href="http://github.com/mrdoob/three.js/blob/master/src/core/Matrix4.js">Matrix4</a> classes from three.js.</p>
<p>The result is quite interesting although it&#8217;s CPU intensive. You can <a target="_blank" href="/wp-content/exp/exp-canvas/index.html">try it here</a> if you have a 2D canvas enabled browser.</p>
<table align="center" style="width:100%;">
<tr>
<td>
<img src="http://i4.ytimg.com/vi/37t8o4MSME8/1.jpg" />
</td>
<td>
<img src="http://i4.ytimg.com/vi/37t8o4MSME8/2.jpg" />
</td>
<td>
<img src="http://i4.ytimg.com/vi/37t8o4MSME8/3.jpg" />
</td>
</tr>
</table>
<p>To make this example I created a Shape object, that would create a list of particles placed in some particular shape:</p>
<pre name="code" class="js:nogutter:nocontrols">
var Shape = {
	Sphere: function(objs, opts) {
		var s = opts.s || 200,
			atan2 = Math.atan2,
			cos = Math.cos,
			acos = Math.acos,
			sin = Math.sin,
			sqrt = Math.sqrt;

		for(var i=0, l=objs.length; i&lt;l; i++) {
			var obj = objs[i],
				pos = obj.pos,
				x = pos.x,
				y = pos.y,
				z = pos.z,
				r = x * x + y * y + z * z,
				theta = acos(z / sqrt(r)),
				phi = atan2(y, (x || 1));

			if(!obj.sphere) {
				obj.sphere = new THREE.Vector4();
			}
			var pos = obj.pos, sphere = obj.sphere;
			pos.x = sphere.x = s * sin(theta) * cos(phi);
			pos.y = sphere.y = s * sin(theta) * sin(phi);
			pos.z = sphere.z = s * cos(theta);
		}
	}
     //...other shapes here...
};
</pre>
<p>I also created a tween object from scratch, which would provide transition equations (linear, Elastic, Bounce) for the particles movement. There are many tweeners around, but since I&#8217;m a big fan of <a href="http://mootools.net/">MooTools</a> and the way they use object mutability and functions as objects to create their tweener I implemented something in that spirit. The transition object code provides an object with methods (Trans.Elastic(<em>delta</em>), Trans.Bounce(<em>delta</em>)) and &#8220;submethods&#8221; as properties of these methods (Trans.Elastic.easeOut(<em>delta</em>), Trans.Bounce.easeInOut(<em>delta</em>)). That&#8217;s the approach I like and I don&#8217;t think it&#8217;s that easy to emulate in other languages&#8230; Will Scala be up to the task? </p>
<p>Here&#8217;s some code for that transitions object:</p>
<pre name="code" class="js:nogutter:nocontrols">
//transitions object. can be used like
//Trans.linear, or Trans.Elastic.easeOut, etc.
var Trans = {
  linear: function(p){
    return p;
  }
};

(function(){

  //add easing equations as methods
  //of the transition object/function
  //i.e add easeIn/Out to the Elastic/Sine objects
  var makeTrans = function(transition, params){
    var trans = {
      easeIn: function(pos){
        return transition(pos, params);
      },
      easeOut: function(pos){
        return 1 - transition(1 - pos, params);
      },
      easeInOut: function(pos){
        return (pos <= 0.5)? transition(2 * pos, params) / 2
          : (2 - transition(2 * (1 - pos), params)) / 2;
      }
    };
	for(var p in trans) {
		transition[p] = trans[p];
	}
	return transition;
  };

  //transition equations
  var transitions = {

    Sine: function(p){
      return 1 - Math.sin((1 - p) * Math.PI / 2);
    },

    Elastic: function(p, x){
      return Math.pow(2, 10 * --p)
          * Math.cos(20 * p * Math.PI * (x[0] || 1) / 3);
    }
    //...other transitions here...
  };

 //enhance the Trans object with new transitons
  for(var p in transitions) {
	Trans[p] = makeTrans(transitions[p]);
  }

})();
</pre>
<p>Finally the main.js file contains <em>init</em>, <em>loop</em> and <em>nextShape</em> functions. The <em>init</em> function will call the Shape object methods, pre-calculating the particles positions, and will set an array with the shapes to iterate on. Loop will render each point to the canvas, by using the <em>x</em> and <em>y</em> coordinates of the particle. The <em>z</em> coordinate will determine the alpha color and radius of the particle. Once a fixed number of loops are triggered nextShape will be called to make the transition to the next shape.</p>
<p>While this is a simple approach, 3D in the 2D canvas environment is quite limited, and very CPU intensive.</p>
<h4>WebGL</h4>
<p>Since most of the code used in the previous example was dealing with 3D objects and then projected into 2D space, this code can also be used when working with WebGL. Getting started with WebGL is much harder than with 2D Canvas though. First, there's all that setup of creating a program, compiling the shaders (which of course is GLSL code and not JavaScript itself), linking them into the program, initializing buffers, etc. Moreover, since there's not a fixed pipeline all that push/pop matrix stack has to be hand-coded now, which makes it quite difficult to create things without a framework. However, since this is a very simple example I used exactly the same things here than in the previous example. <a target="_blank" href="/wp-content/exp/exp-webgl/index.html">Here's the live example that you can see in a WebGL enabled browser</a> (click <a href="http://learningwebgl.com/blog/?p=11">here</a> to get a WebGL enabled browser). Or you can check the video I made of the demo below (click <a href="http://www.youtube.com/watch?v=qVt-R7KaULA">here</a> if you can't see the video):</p>
<p><object width="500" height="400"><param name="movie" value="http://www.youtube.com/v/qVt-R7KaULA?fs=1&amp;hl=en_US&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/qVt-R7KaULA?fs=1&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="400"></embed></object></p>
<p>The rendering part is quite different though. You need to set all the vertex information into a buffer and send that data into the shaders. The shaders will get the data in attributes (which is per vertex information) or uniforms (data which will remain the same for all vertices). For example, all particles are colored the same, but each particle has a different position, so the code would look like this:</p>
<pre name="code" class="js:nogutter:nocontrols">
    //draw scene
    gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
    gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
    perspective(45, gl.viewportWidth / gl.viewportHeight, 0.1, 500.0);
    loadIdentity();
    mvTranslate([0.0, 0.0, -150.0]);
    mvRotateX(rx);
    mvRotateY(ry);
    for(var i=0, l=parts.length, vertices=[]; i&lt;l; i++) {
        var p = parts[i].pos;
        vertices.push(p.x, p.y, p.z);
    }
    //create and store and bind vertex data
    gl.bindBuffer(gl.ARRAY_BUFFER, ballsPositionBuffer);
    gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
    gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute,
                           ballsPositionBuffer.itemSize,
                           gl.FLOAT, false, 0, 0);
    //set model view and perspective matrix
    setMatrixUniforms();
    //set color and object scaling
    gl.uniform1f(shaderProgram.scaleUniform, s);
    gl.uniform3f(shaderProgram.colorUniform, r, g, b);
    //draw
    gl.drawArrays(gl.POINTS, 0, ballsPositionBuffer.numItems);
</pre>
<p>While it can be a little bit difficult to dive into WebGL from scratch, this is definitely the way to go if you want to make some serious 3D stuff in the browser. Plus, once you get some base code right, things become quite simple <img src='http://blog.thejit.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  .<br />
Chrome/Safari and Firefox have pretty mature implementations of WebGL, and just like it happened with 2D canvas, I bet this will be eventually implemented in other browsers as well.</p>
<h4>SPDE = Scala + Processing</h4>
<p>Since OCaml is dead and I really liked some features of it such as type inference, destructuring, pattern matching, object literals, operator overloading and more, I looked for some replacement and considered Scala as an interesting alternative. I'm still learning Scala, and while being more OO and less functional than OCaml, there's still room for pattern matching with <a href="http://www.scala-lang.org/node/107">case classes</a>, syntactic sugar for singletons (or object literals), and other goodies such as <a href="http://www.scala-lang.org/node/126">traits</a>, operator overloading, etc. <b>Plus, it targets the JVM</b>.<br />
<a href="http://technically.us/spde/About">SPDE</a> is the "port" of the Processing Development Environment to the Scala programming language. It basically provides a nice workflow to create and run projects, providing the <a href="http://processing.org/reference/">set of drawing methods</a> that already exist in Processing. The SPDE project is <a href="http://github.com/n8han/spde">hosted at Github</a> as well as the <a href="http://github.com/n8han/spde-examples">SPDE Examples</a>.</p>
<p>The structure of the code I ported is quite similar to the WebGL example code, but more high-level in the sense that there are lots of drawing primitives and useful functions within the Processing environment. I really enjoyed hacking this thing with Scala. Here's <a href="http://github.com/philogb/spde-examples/blob/master/FractalParticles/FractalParticles.spde">the source code for the example</a>. You can also watch a video of the visualization below (click <a href="http://www.youtube.com/watch?v=Fl-V7GRAJJ4">here</a> if you can't watch the video):</p>
<p><object width="500" height="400"><param name="movie" value="http://www.youtube.com/v/Fl-V7GRAJJ4?fs=1&amp;hl=en_US&amp;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Fl-V7GRAJJ4?fs=1&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="400"></embed></object></p>
<p>Remember the code for the tweener I described before? Some really nice feature in Scala is that you can extend the class <b>Function</b> which provides mappings from one type to another. In Scala functions are also treated as classes and the "elegant" code done for creating transitions in JavaScript can be "ported" to Scala in that same way:</p>
<pre name="code" class="python:nogutter:nocontrols">
abstract class Transitions extends Function[Float, Float] {
 private def easeInVar(x: Float, i: Float = 1.0): Float = apply(i * x);
 private def easeOutVar(x: Float, i: Float = 1.0): Float = i - apply(i * (1 - x));

 def easeIn(x: Float) = easeInVar(x);
 def easeOut(x: Float) = easeOutVar(x);
 def easeInOut(x: Float): Float = (if (x &lt;= 0.5) easeInVar(x, 2) else easeOutVar(x, 2)) /2
}

object Transitions {
 private val pi = Pi;

 def linear(x: Float) = x;

 object Sine extends Transitions {
  override def apply(x: Float): Float = 1 - sin((1 - x) * pi / 2)
 }

 object Back extends Transitions {
  override def apply(p: Float): Float = {
   val x = 1.618;
   pow(p, 2) * ((x + 1) * p - x);
  }
 }
       //...other objects here...
}
</pre>
<p>So now transitions can be passed as parameters just like with JavaScript:</p>
<pre name="code" class="java:nogutter:nocontrols">
Transitions.linear _;
Transitions.Elastic.easeOut _;
</pre>
<p>This is due to the fact that there's some syntactic sugar for the apply method for a Function instance:</p>
<pre name="code" class="java:nogutter:nocontrols">
Transitions.Elastic.apply(0.5); //is the same as...
Transitions.Elastic(0.5);

Transitions.Elastic.easeOut.apply(0.5); //is the same as...
Transitions.Elastic.easeOut(0.5);
</pre>
<h4>Conclusion</h4>
<p>There are many approaches to do graphics and I only used three of them. For 2D Canvas rendering in 3D there are some libraries worth taking at look at: <a href="http://github.com/mrdoob/three.js">three.js</a> and <a href="http://deanm.github.com/pre3d/">pre3d</a>. If you'd like to learn WebGL (highly recommended) I recommend the webgl lessons page found <a href="http://learningwebgl.com/blog/?page_id=1217">here</a>. Finally, <a href="http://technically.us/spde/About">SPDE</a> is a great way to learn Scala and Processing at the same time. It's definitely worth taking a look at it.</p>
<img src="http://feeds.feedburner.com/~r/Noumena/~4/1GtuuyYtNXw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2010/09/04/three-ways-to-make-3d/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://blog.thejit.org/2010/09/04/three-ways-to-make-3d/</feedburner:origLink></item>
		<item>
		<title>JavaScript InfoVis Toolkit 2.0.0 beta released</title>
		<link>http://feedproxy.google.com/~r/Noumena/~3/G06fyy87QOA/</link>
		<comments>http://blog.thejit.org/2010/08/10/javascript-infovis-toolkit-2-0-0-beta-released/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 20:37:10 +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=1568</guid>
		<description><![CDATA[After many bug fixes, some tweaks to the documentation and new features the JavaScript InfoVis Toolkit 2.0.0 beta is ready!
Most of the bug fixes were on the TreeMap visualization, the generic graph morph operation, the Events system and the AreaChart visualization. If you&#8217;d like to see the commits in more detail you can take a [...]]]></description>
			<content:encoded><![CDATA[<p>After many bug fixes, some tweaks to the documentation and new features the <a href="http://thejit.org/">JavaScript InfoVis Toolkit</a> 2.0.0 beta is ready!<br />
Most of the bug fixes were on the TreeMap visualization, the generic graph morph operation, the Events system and the AreaChart visualization. If you&#8217;d like to see the commits in more detail you can take a look <a href="http://github.com/philogb/jit/commits/master">here</a>.<br />
Some API enhancements include the ability to add edge events. This is still kind of an experimental feature, but if you&#8217;d like to know more about this you can read the <a href="http://thejit.org/static/v20/Docs/files/Options/Options-Events-js.html">Options.Events documentation</a>.<br />
The main reason to tag this as a beta release is that besides some <a href="http://github.com/philogb/jit/issues">known issues</a> this version has proved to be pretty stable. This version is currently being used at <a href="http://exalead.com">Exalead</a> for customer projects and proved to be reliable. <a href="http://googlewavedev.blogspot.com/2010/07/wave-visualizer-turning-trees-into.html">Google</a> and <a href="http://www.mozilla.org/community/universe.html">Mozilla</a> are also using the toolkit, which is great news.</p>
<h4>Builder</h4>
<p>With this beta release I&#8217;m also releasing a <a href="http://thejit.org/builder/">custom toolkit builder</a>. The custom builder enables you to make your own build by choosing the visualizations you need and keeping out the code of the visualizations you don&#8217;t need. As more visualizations get added to the toolkit this will be a key component to optimize your web page loading. Currently the <a href="http://thejit.org/builder/">builder</a> is on an experimental phase, but I strongly recommend you to check it out, custom builds can make a strong optimization difference.</p>
<img src="http://feeds.feedburner.com/~r/Noumena/~4/G06fyy87QOA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2010/08/10/javascript-infovis-toolkit-2-0-0-beta-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.thejit.org/2010/08/10/javascript-infovis-toolkit-2-0-0-beta-released/</feedburner:origLink></item>
		<item>
		<title>Doctor Who villains from 1963 to 2010 visualized</title>
		<link>http://feedproxy.google.com/~r/Noumena/~3/I_YT_sX50oc/</link>
		<comments>http://blog.thejit.org/2010/07/17/doctor-who-villains-from-1963-to-2010-visualized/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 21:34:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=1530</guid>
		<description><![CDATA[While browsing the internet I got to the Guardian&#8217;s Datablog, a blog that gathers interesting information and datasets to explore and make visualizations. Latest post was about Every Doctor Who villain since 1963. There&#8217;s information about each villain&#8217;s first and last year of appearance, their motivation/evil plan, the name of the actors who played the [...]]]></description>
			<content:encoded><![CDATA[<p>While browsing the internet I got to the <a href="http://www.guardian.co.uk/news/datablog">Guardian&#8217;s Datablog</a>, a blog that gathers interesting information and datasets to explore and make visualizations. Latest post was about <a href="http://www.guardian.co.uk/news/datablog/2010/jul/16/doctor-who-villains-list">Every Doctor Who villain since 1963</a>. There&#8217;s information about each villain&#8217;s first and last year of appearance, their motivation/evil plan, the name of the actors who played the role of Doctor Who while that villain was making an appearance, the title of the stories where that villain was in, etc.</p>
<p>I created a &#8220;dynamic&#8221; TreeMap visualization with that data. Here&#8217;s a short screencast I made explaining the TreeMap functionalities (I have a horrible english accent&#8230; I know). You can also play with the demo <a href="http://demos.thejit.org/doctorwho/">here</a>.</p>
<p><object width="500" height="400"><param name="movie" value="http://www.youtube.com/v/vAGk9gIzzEM&amp;hl=en_US&amp;fs=1?rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/vAGk9gIzzEM&amp;hl=en_US&amp;fs=1?rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="400"></embed></object></p>
<h4>The Code</h4>
<p>For this example I used a special build of the Toolkit which is currently hosted at <a href="http://github.com/philogb/jit">GitHub</a>. The TreeMap example code looks just like the <a href="http://thejit.org/demos/">TreeMap demos code</a> but I also added an <em>onBeforeCompute</em> callback that checks for the <em>Doctor Actor Name</em> and <em>Villain Motivation</em> filters to fade nodes respectively:</p>
<pre name="code" class="js:nogutter:nocontrols">
onBeforeCompute: function() {
  tm.graph.eachNode(function(n) {
    var prev = false;
    if(n.data.motivations) {
      prev = true;
      if(motivation != 'All'
        &#038;&#038; n.data.motivations.indexOf(motivation) == -1) {
        n.setData('alpha', 0, 'end');
        n.ignore = true;
      } else {
        n.setData('alpha', 1, 'end');
        delete n.ignore;
      }
    }
    if(n.data.doctorActorNames) {
      if(doctorName != 'All'
        &#038;&#038; n.data.doctorActorNames.indexOf(doctorName) == -1) {
        n.setData('alpha', 0, 'end');
        n.ignore = true;
      } else if(!prev) {
        n.setData('alpha', 1, 'end');
        delete n.ignore;
      }
    }
  });
},
</pre>
<p>The anchor click callbacks set the current selected value to the <em>doctorName</em> and <em>motivation</em> variables and also perform an animation by fading nodes and repositioning the remaining visible nodes:</p>
<pre name="code" class="js:nogutter:nocontrols">
anchors.addEvent('click', function(e) {
  doctorName = this.innerHTML;
  tm.compute('end');
  tm.fx.animate({
    modes: {
      position: 'linear',
      'node-property': ['alpha', 'width', 'height']
    },
    duration: 1000,
    fps: 50,
    transition: $jit.Trans.Quart.easeInOut
  });
});
</pre>
<p>The <em>tm.compute(&#8216;end&#8217;);</em> call will trigger the <em>onBeforeCompute</em> callback that will set correct alpha values for the nodes. Then we perform an animation of node positions and node alpha, width and height properties.</p>
<p>I hope you have fun with the <a href="http://demos.thejit.org/doctorwho/">demo</a>!</p>
<img src="http://feeds.feedburner.com/~r/Noumena/~4/I_YT_sX50oc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2010/07/17/doctor-who-villains-from-1963-to-2010-visualized/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.thejit.org/2010/07/17/doctor-who-villains-from-1963-to-2010-visualized/</feedburner:origLink></item>
		<item>
		<title>Speaker at JSConf.eu 2010</title>
		<link>http://feedproxy.google.com/~r/Noumena/~3/TS-N2iTAm38/</link>
		<comments>http://blog.thejit.org/2010/07/08/speaker-at-jsconf-eu-2010/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 21:09:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>
		<category><![CDATA[talk]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=1517</guid>
		<description><![CDATA[Update: The presentation page is here.
Just a quick post to tell you that I&#8217;ve been selected to speak at JSConf.eu 2010 in Berlin in September. JSConf.eu is the most important JavaScript conference held in Europe. Last year speakers included John Resig, Douglas Crockford and 280 north people among others. I&#8217;m very excited about this event [...]]]></description>
			<content:encoded><![CDATA[<p><em>Update: The presentation page is <a href="http://jsconf.eu/2010/speaker/creating_interactive_data_visu.html">here</a></em>.</p>
<p>Just a quick post to tell you that I&#8217;ve been selected to speak at <a href="http://jsconf.eu">JSConf.eu 2010</a> in Berlin in September. <a href="http://jsconf.eu">JSConf.eu</a> is the most important JavaScript conference held in Europe. <a href="http://jsconf.eu/2009/speakers.html">Last year speakers</a> included <a href="http://en.wikipedia.org/wiki/John_Resig">John Resig</a>, <a href="http://en.wikipedia.org/wiki/Douglas_Crockford">Douglas Crockford</a> and <a href="http://280north.com/">280 north people</a> among others. I&#8217;m very excited about this event and I can&#8217;t wait to meet everyone there!</p>
<p>More updates will come in the next few days. You can also follow feeds from the <a href="http://jsconf.eu">main page event</a> or follow them on <a href="http://twitter.com/jsconfeu">twitter</a>. Oh, I have a <a href="http://twitter.com/philogb">twitter account</a>, too <img src='http://blog.thejit.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/Noumena/~4/TS-N2iTAm38" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2010/07/08/speaker-at-jsconf-eu-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.thejit.org/2010/07/08/speaker-at-jsconf-eu-2010/</feedburner:origLink></item>
		<item>
		<title>The JavaScript InfoVis Toolkit 2.0 is out!</title>
		<link>http://feedproxy.google.com/~r/Noumena/~3/L0wHryzew0Q/</link>
		<comments>http://blog.thejit.org/2010/06/28/the-javascript-infovis-toolkit-2-0-is-out/#comments</comments>
		<pubDate>Mon, 28 Jun 2010 12:01:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[2.0]]></category>
		<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[version]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=1492</guid>
		<description><![CDATA[After more than a year of hard work I&#8217;m proud to announce the release of the JavaScript InfoVis Toolkit 2.0!
What&#8217;s the JavaScript InfoVis Toolkit?
The JavaScript InfoVis Toolkit provides web standard based tools to create interactive data visualizations for the Web.
What&#8217;s new in this version?
This version introduces radical new features, an API redesign and new visualizations. [...]]]></description>
			<content:encoded><![CDATA[<p>After more than a year of hard work I&#8217;m proud to announce the release of the <a target="_blank" href="http://thejit.org">JavaScript InfoVis Toolkit 2.0</a>!</p>
<h4>What&#8217;s the JavaScript InfoVis Toolkit?</h4>
<p>The <a target="_blank" href="http://thejit.org">JavaScript InfoVis Toolkit</a> provides web standard based tools to create interactive data visualizations for the Web.</p>
<h4>What&#8217;s new in this version?</h4>
<p>This version introduces radical new features, an API redesign and new visualizations. If you don&#8217;t want to read the whole article and just want to play with the examples you can go to <a href="http://thejit.org/demos/" target="_blank">the demos page</a>.</p>
<h4>New Visualizations</h4>
<p>With this version of the Toolkit the number of available visualizations has doubled. Some of the new visualizations are the AreaChart, BarChart and PieChart, which were described in more detail in <a href="http://blog.thejit.org/2010/04/24/new-javascript-infovis-toolkit-visualizations/">this article</a>. I&#8217;ve also added Sunburst and Force-Directed visualizations. I wrote about these visualizations before <a href="http://blog.thejit.org/2009/10/05/sunburst-visualization/">here</a> and <a href="http://blog.thejit.org/2009/09/30/force-directed-layouts/">here</a>. I also want to thank <a href="http://quux.com.ar" target="_blank">Pablo Flouret</a>, who contributed most of the code for the Icicle visualization, also a new addition to the toolkit.</p>
<p>You can play now with these visualizations at the <a href="http://thejit.org/demos/">demos page</a>!</p>
<h4>Features common to all visualizations</h4>
<p>I&#8217;ve also enhanced all visualizations with new configuration options that enable new features. These features are:</p>
<ul>
<li><em>Panning</em> and <em>zooming</em> across all visualizations.</li>
<li>A new <em>event system</em> that enables you to attach events to DOM elements or to native canvas nodes and also add support for <em>touch events</em>, <em>drag and drop</em>, etc.</li>
<li><em>Complex animations</em> have the ability to animate <b>any style property</b> of a node, edge or label. There is also support for animating canvas specific properties like shadowBlur, shadowColor, fillStyle, etc.</li>
</ul>
<h4>A new TreeMap visualization</h4>
<p>The underlying rendering functions in the TreeMap visualization have changed. While in prior versions of the Toolkit the TreeMap was DOM-based, this new version renders the TreeMap entirely in Canvas. This enables you to add custom nodes of any shape or nature you like (can be images, circles, polygons) and also to take advantage of the new animation engine of the toolkit to add smooth transitions for the drill-down. These new things can be tested at the TreeMap section in the <a target="_bank" href="http://thejit.org/demos/">demos page</a>.</p>
<h4>API Redesign</h4>
<p>The old API was too low level. Before creating any visualization you had to manually create a Canvas widget and pass it as parameter to the visualization class. Also, many other parameters like width and height of the canvas were required. For Background canvases the API had a couple of flaws, and it wasn&#8217;t clear how to use it either. Many of these things have been solved with the new API design. The Canvas class became an inner class implicitly created when making a new visualization. Width and height of the canvas are set to the container&#8217;s <em>offsetWidth</em> and <em>offsetHeight</em> if they&#8217;re not provided, and background canvases are easier to attach to the visualization.<br />
Most of all, there is now a single global object in the library: <b>$jit</b>. This declares the namespace for the library and makes sure you won&#8217;t have conflicts with <em>any other JavaScript library</em>.</p>
<h4>A new Website</h4>
<p>Last but not least, I worked on a <a href="http://thejit.org/">website redesign</a>, taking advantage of the new HTML5/CSS3 features supported by major browsers. There&#8217;s also a detailed <a href="http://thejit.org/docs/">documentation page</a> to get you started.</p>
<h4>It&#8217;s alpha</h4>
<p>Finally I&#8217;d like to say that this is an <em>alpha</em> version. There are lots of known bugs and <b>I&#8217;m counting on you</b> to <a href="http://github.com/philogb/jit">report bugs, send fixes, and collaborate in any aspect of the toolkit</a>.</p>
<h4>Thanks</h4>
<p>To <a href="http://quux.com.ar">Pablo Flouret</a> for contributing code to the toolkit, and to my wife, <a href="http://sourberries.tumblr.com/">Luz Caballero</a> for making me happy.</p>
<p>Now go get the <a href="http://thejit.org/">Toolkit</a>!</p>
<img src="http://feeds.feedburner.com/~r/Noumena/~4/L0wHryzew0Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2010/06/28/the-javascript-infovis-toolkit-2-0-is-out/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		<feedburner:origLink>http://blog.thejit.org/2010/06/28/the-javascript-infovis-toolkit-2-0-is-out/</feedburner:origLink></item>
		<item>
		<title>News from the JavaScript InfoVis Toolkit 2.0 World</title>
		<link>http://feedproxy.google.com/~r/Noumena/~3/SL4WAn1_g9w/</link>
		<comments>http://blog.thejit.org/2010/05/30/news-from-the-javascript-infovis-toolkit-2-0-world/#comments</comments>
		<pubDate>Sun, 30 May 2010 18:35:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[visualization]]></category>
		<category><![CDATA[javascript infovis toolkit]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=1476</guid>
		<description><![CDATA[We&#8217;re not that far. Not at all. I was actually going to write some completion percentage, but I think I&#8217;ll just leave that as a mystery and surprise you when the time comes. But until then&#8230; some videos from the 2.0 world!
Animated TreeMaps
In order to show some of the new features I&#8217;ve been writing a [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re not that far. Not at all. I was actually going to write some completion percentage, but I think I&#8217;ll just leave that as a mystery and surprise you when the time comes. But until then&#8230; some videos from the 2.0 world!</p>
<h4>Animated TreeMaps</h4>
<p>In order to show some of the new features I&#8217;ve been writing a simple example with TreeMap animations. TreeMap animations are integrated into the built-in classes of the Toolkit, but you can also create your own animations by altering either built-in Node/Edge params, or also canvas specific styles like shadows.</p>
<p>Here&#8217;s a short video of an Animated TreeMap, it also has animations when switching layouts. I think it&#8217;s better seen in fullscreen.</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/KaEvu5YRwLk&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/KaEvu5YRwLk&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<h4>Zooming and Panning</h4>
<p>The new Event system allows many customizations, such as Dragging and Dropping nodes, (right)clicking native Canvas nodes, etc. This will be the subject of a longer post, since there is a lot of machinery involving Native Canvas, SVG and HTML events, event delegation, etc. I&#8217;ve also been working in making a modular Canvas class enabling canvas background extensions.</p>
<p>Some of these changes had some desirable effects, such as enabling Panning and Zooming in a generic way, across all visualizations, as can be seen in this video:</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/CpXpAiZT1n0&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/CpXpAiZT1n0&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<h4>A Force Directed Example</h4>
<p>These features can be combined into useful and interesting examples. This Force Directed example uses the new Event system, zooming, panning and animations to make a complete graph editing tool. These are some of the graph interactions that can be made with the JavaScript InfoVis Toolkit (also better seen in fullscreen):</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/gSdlgRSEy_s&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/gSdlgRSEy_s&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>I hope you liked it. I know I&#8217;m having a great time working in this project. </p>
<p>I&#8217;ll be back with more updates.</p>
<img src="http://feeds.feedburner.com/~r/Noumena/~4/SL4WAn1_g9w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2010/05/30/news-from-the-javascript-infovis-toolkit-2-0-world/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://blog.thejit.org/2010/05/30/news-from-the-javascript-infovis-toolkit-2-0-world/</feedburner:origLink></item>
		<item>
		<title>Browser Photo Mosaics</title>
		<link>http://feedproxy.google.com/~r/Noumena/~3/3nyGbTAHEzs/</link>
		<comments>http://blog.thejit.org/2010/05/20/browser-photo-mosaics/#comments</comments>
		<pubDate>Thu, 20 May 2010 18:12:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[exalead]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[visualization]]></category>
		<category><![CDATA[mosaic]]></category>
		<category><![CDATA[photo mosaic]]></category>
		<category><![CDATA[photos]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=1458</guid>
		<description><![CDATA[Update: I made a video showing the Photo Mosaic process + zoomable Canvas here:

Today, I started working at Exalead on a photo mosaic service that could take advantage of Exalead&#8217;s Search Engine. The service contains a bunch of indexed images from different sources. These images are categorized by color just like the images in our [...]]]></description>
			<content:encoded><![CDATA[<p><em>Update: I made a video showing the Photo Mosaic process + zoomable Canvas here:</em></p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/eJP_IgXEv6s&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/eJP_IgXEv6s&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>Today, I started working at <a href="http://exalead.com">Exalead</a> on a photo mosaic service that could take advantage of Exalead&#8217;s Search Engine. The service contains a bunch of indexed images from different sources. These images are categorized by color just like the images in our <a href="http://www.exalead.com/search/image/results/?q=exalead">public search service</a>, allowing us to easily find pictures by approximating colors.</p>
<p>I decided to run the web application into some browser logos to see what the results were. You can click the images to enlarge. </p>
<h4>Chrome</h4>
<p><a href="/wp-content/static/img/chrome1.png"><img  src="/wp-content/static/img/chrome1_500.png" style="border: 1px solid cyan; padding: 3px; margin: 0px 13px 5px 0;" /><br />
</a></p>
<h4>IE</h4>
<p><a href="/wp-content/static/img/ie.png"><img  src="/wp-content/static/img/ie_500.png" style="border: 1px solid cyan; padding: 3px; margin: 0px 13px 5px 0;" /><br />
</a></p>
<h4>Firefox</h4>
<p><a href="/wp-content/static/img/ff1.png"><img  src="/wp-content/static/img/ff1_500.png" style="border: 1px solid cyan; padding: 3px; margin: 0px 13px 5px 0;" /><br />
</a></p>
<h4>Opera</h4>
<p><a href="/wp-content/static/img/opera1.png"><img  src="/wp-content/static/img/opera1_500.png" style="border: 1px solid cyan; padding: 3px; margin: 0px 13px 5px 0;" /><br />
</a></p>
<h4>Safari</h4>
<p><a href="/wp-content/static/img/safari.png"><img  src="/wp-content/static/img/safari_500.png" style="border: 1px solid cyan; padding: 3px; margin: 0px 13px 5px 0;" /><br />
</a></p>
<p>Safari was kind of complicated because the logo has more details than the others. I also made a close up of the logo:<br />
<a href="/wp-content/static/img/safari2.png"><br />
<img  src="/wp-content/static/img/safari2_500.png" style="border: 1px solid cyan; padding: 3px; margin: 5px 13px 5px 0;" /><br />
</a></p>
<p>Which one do you like the most?</p>
<img src="http://feeds.feedburner.com/~r/Noumena/~4/3nyGbTAHEzs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2010/05/20/browser-photo-mosaics/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://blog.thejit.org/2010/05/20/browser-photo-mosaics/</feedburner:origLink></item>
		<item>
		<title>Speaker at YOW! Australia 2010</title>
		<link>http://feedproxy.google.com/~r/Noumena/~3/NCyGe4B5j2M/</link>
		<comments>http://blog.thejit.org/2010/05/03/speaker-at-yow-australia-2010/#comments</comments>
		<pubDate>Mon, 03 May 2010 18:57:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[talk]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=1456</guid>
		<description><![CDATA[Just a quick post to tell you that I&#8217;ve been invited to speak at YOW! Australia Developer Conference in Brisbane and Melbourne in December. YOW! is the new name for the JAOO (a.k.a Java and OO) conferences that have been running for over 13 years around the world already. YOW! Australia 2010 will include talks [...]]]></description>
			<content:encoded><![CDATA[<p>Just a quick post to tell you that I&#8217;ve been invited to speak at <a href="http://www.yowconference.com.au/">YOW! Australia Developer Conference</a> in Brisbane and Melbourne in December. YOW! is the new name for the <a href="http://jaoo.dk/">JAOO</a> (a.k.a Java and OO) conferences that have been running for over 13 years around the world already. <a href="http://www.yowconference.com.au/">YOW! Australia 2010</a> will include talks by <a href="http://www.yowconference.com.au/brisbane/speakers/details.html?speakerId=1616">Guy L. Steele, Jr.</a>, <a href="http://www.yowconference.com.au/brisbane/speakers/details.html?speakerId=1635">Erik Meijer</a> and me among others -yes, I can&#8217;t believe I just put myself in the same list as these people!.</p>
<p>Anyway, I&#8217;ll keep you updated.</p>
<img src="http://feeds.feedburner.com/~r/Noumena/~4/NCyGe4B5j2M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2010/05/03/speaker-at-yow-australia-2010/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://blog.thejit.org/2010/05/03/speaker-at-yow-australia-2010/</feedburner:origLink></item>
		<item>
		<title>New JavaScript InfoVis Toolkit Visualizations</title>
		<link>http://feedproxy.google.com/~r/Noumena/~3/wl2k6Mn3ncA/</link>
		<comments>http://blog.thejit.org/2010/04/24/new-javascript-infovis-toolkit-visualizations/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 01:41:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript information visualization toolkit (JIT)]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=1437</guid>
		<description><![CDATA[Today I&#8217;d like to announce the addition of three new components in the next version of the JavaScript InfoVis Toolkit: Area Charts, Bar Charts and Pie Charts. I hope these components will be widely used among the JIT user community.
All components support a simpler JSON format that I&#8217;ll describe later in this post. These components [...]]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;d like to announce the addition of three new components in the next version of the <a href="http://thejit.org">JavaScript InfoVis Toolkit</a>: Area Charts, Bar Charts and Pie Charts. I hope these components will be widely used among the JIT user community.</p>
<p>All components support a simpler JSON format that I&#8217;ll describe later in this post. These components are easy-to-use, yet very powerful: they support live data updates and multi valued data as we will see next.</p>
<h4>Area Charts</h4>
<p>The Area Chart is a useful component to track the evolution of a bunch of categories at the same time. In addition, the aggregation of the values of all these categories is also presented in a meaningful way. This component supports live updates (as you&#8217;ll see in the first seconds of the video), filtering/restoring categories, tooltips and a legend. As usual this is all JavaScript:</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/NcpFzSkIJOM&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/NcpFzSkIJOM&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>The visualization is instanciated this way:</p>
<pre name="code" class="js:nogutter:nocontrols">
var areaChart = new $jit.AreaChart({
    //id of the container
    injectInto: 'infovis',
    //set animations
    animate: true,
    //visualization 'padding'
    offset: 5,
    //labels 'margin'
    labelOffset:10,
    //show aggregated values
    showAggregates:true,
    //show labels
    showLabels:true,
    //use gradients for rendering
    type:'stacked:gradient',
    //label styling
    Label: {
      size: 13,
      family: 'Arial',
      color: 'white'
    },
    //enable tips
    Tips: {
      enable: true,
      onShow: function(tip, elem) {
         tip.innerHTML = "<b>" + elem.name + "</b>: " + elem.value;
      }
    },
    //add leftclick handler
    filterOnClick: true,
    //add rightclick handler
    restoreOnRightClick:true
});
</pre>
<p>Additionally this visualization allows programmatic category filtering, JSON updating, selecting you own colors, etc.</p>
<h4>Bar Charts</h4>
<p>Bar Charts are similar to Area Charts, but they support additional styling and positioning. You can use vertical or horizontal Bar Charts. Here&#8217;s an example:</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/wkVBQvZ1LsM&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/wkVBQvZ1LsM&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<p>This object is created the same way you create an AreaChart:</p>
<pre name="code" class="js:nogutter:nocontrols">
var barChart = new $jit.BarChart({
    injectInto: 'infovis',
    animate: true,
    //set orientation vertical or horizontal
    orientation: 'horizontal',
    //bar separation
    barsOffset: 20,
    offset:10,
    labelOffset:5,
    type:'stacked:gradient',
    showAggregates:true,
    showLabels:true,
    Label: {
      size: 13,
      family: 'Arial',
      color: 'white'
    },
    Tips: {
      'enable': true,
      'onShow': function(tip, elem) {
         tip.innerHTML = "<b>" + elem.name + "</b>: " + elem.value;
      }
    }
});
</pre>
<h4>Pie Charts / Rose Diagrams</h4>
<p>Finally there&#8217;s the Pie Chart. But this is no regular Pie Chart. It can support simple data as well as more complex data. You can add multiple categories to this Pie Chart, combining them into something more like a Stacked Rose Diagram. They also support live updates as you&#8217;ll see in the first seconds of the video:</p>
<p><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/0bmWXM3j7Rs&#038;hl=en_US&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/0bmWXM3j7Rs&#038;hl=en_US&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></p>
<h4 id="json-data-format">JSON Data Format</h4>
<p>The JSON data format for these visualizations had to depict something like a contingency table, and so I decided to adopt something like this:</p>
<pre name="code" class="js:nogutter:nocontrols">
var json = {
    //category labels
    'label': ['label A', 'label B', 'label C', 'label D'],
    //each "stack" is described here
    'values': [
    {
      'label': 'date A',
      'values': [20, 40, 15, 5]
    },
    {
      'label': 'date B',
      'values': [30, 10, 45, 10]
    },
    {
      'label': 'date E',
      'values': [38, 20, 35, 17]
    },
    {
      'label': 'date F',
      'values': [58, 10, 35, 32]
    },
    {
      'label': 'date D',
      'values': [55, 60, 34, 38]
    },
    {
      'label': 'date C',
      'values': [26, 40, 25, 40]
    }]
};
</pre>
<p>I hope you find these visualizations useful, and if you can&#8217;t wait for the next version to come out to use these charts you can always build the project from <a href="http://github.com/philogb/jit">GitHub</a>. Here&#8217;s a <a href="http://wiki.github.com/philogb/jit/getting-started">wiki</a> with some instructions on how to make your own build of the library while you&#8217;re waiting for an official release. If you ever find bugs please use the <a href="http://github.com/philogb/jit/issues">issue tracker at GitHub</a>. If you need help or have any questions you can always go to the <a href="http://groups.google.com/group/javascript-information-visualization-toolkit/">Google Group</a>. Well, this got long enough. </p>
<p>Hope you enjoyed it!</p>
<img src="http://feeds.feedburner.com/~r/Noumena/~4/wl2k6Mn3ncA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2010/04/24/new-javascript-infovis-toolkit-visualizations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://blog.thejit.org/2010/04/24/new-javascript-infovis-toolkit-visualizations/</feedburner:origLink></item>
		<item>
		<title>JavaScript Animations</title>
		<link>http://feedproxy.google.com/~r/Noumena/~3/CXtc9to58Uw/</link>
		<comments>http://blog.thejit.org/2010/03/25/javascript-animations/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 20:44:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[animation]]></category>

		<guid isPermaLink="false">http://blog.thejit.org/?p=1401</guid>
		<description><![CDATA[JavaScript animations are a key aspect of dynamic Web Sites and Application development. Moreover, most JavaScript Frameworks or Libraries provide APIs for dealing with at least three main things:

Advanced DOM manipulation
Ajax
Animations

When developing Web Sites most JavaScript effects involve rendered DOM Elements, but sometimes JavaScript animations are used in other contexts, like when using the Canvas. [...]]]></description>
			<content:encoded><![CDATA[<p>JavaScript animations are a key aspect of dynamic Web Sites and Application development. Moreover, most JavaScript Frameworks or Libraries provide APIs for dealing with at least three main things:</p>
<ul>
<li>Advanced DOM manipulation</li>
<li>Ajax</li>
<li>Animations</li>
</ul>
<p>When developing Web Sites most JavaScript effects involve rendered DOM Elements, but sometimes JavaScript animations are used in other contexts, like when using the Canvas. In the <a href="http://thejit.org">JavaScript InfoVis Toolkit</a> the main target of my animations are Graphs, and in the next version also Nodes and Edges as separate entities.</p>
<p>Today I&#8217;d like to describe how to create a generic animation class that can be used or extended for any purpose. I&#8217;ll try to be minimalistic and to present only the needed code for making animations. Then you might find useful to add some code to perform specific animation tasks targeting for example specific style properties of a DOM Element.</p>
<h4>Defining an Animation Class</h4>
<p>Before creating an Animation class we might want to consider what to expose as options to the user. The options I thought of are:</p>
<ul>
<li>The duration of the animation (in milliseconds)</li>
<li>The frames per second of the animation</li>
</ul>
<p>Additionally we&#8217;d like to add a couple of controllers, one when a step of the animation is executed and one when the animation has completed:</p>
<pre name="code" class="js:nogutter">
var options = {
  duration: 1000,
  fps: 40,
  onStep: function(delta) {},
  onComplete: function() {}
};
</pre>
<p><em>delta</em> gives us an idea of the <em>progress</em> of the animation. When the animation starts delta will be equal to zero. When the animation ends it&#8217;ll be equal to one.</p>
<p>We will also need a <em>start</em> method to trigger the animation and a <em>step</em> method that will compute <em>delta</em> at each step.</p>
<p>Now that we defined our options we can start thinking about our implementation.</p>
<h4>Implementing the Animation class</h4>
<p>Our Animation class will be a class constructor that sets all the options and properties that we defined before and a prototype with the methods <em>start</em> and <em>step</em>. The class could be used like this:</p>
<pre name="code" class="js:nogutter">
var fx = new Effect({
  duration: 1000,
  fps: 40,
  onStep: function(delta) {
    /* do stuff */
  },
  onComplete: function() {
    alert('done!');
  }
});
//start the animation
fx.start();
</pre>
<p>Here&#8217;s the code I came up with, inspired by the <a href="http://mootools.net">MooTools</a> Framework:</p>
<pre name="code" class="js:nogutter">
//define the class constructor
function Effect(opt) {
  this.opt = {
    duration: opt.duration || 1000,
    fps: opt.fps || 40,
    onStep: opt.onStep || function(){},
    onComplete: opt.onComplete || function(){}
  };
}

Effect.prototype = {
  //define how the animation starts
  start: function() {
    //return if we're currently performing an animation
    if(this.timer) return;
    //trigger the animation
    var that = this, fps = this.opt.fps;
    this.time = +new Date;
    this.timer = setInterval(function() { that.step(); },
                             Math.round(1000/fps));
  },
  //triggered at each interval step
  step: function() {
    var currentTime = +new Date, time = this.time, opt = this.opt;
   //check if the time interval already exceeds the duration
   if(currentTime < time + opt.duration) {
     //if not, calculate our animation progress
      var delta = (currentTime - time) / opt.duration;
      opt.onStep(delta);
    } else {
      //we already exceeded the duration, stop the effect
      //and call the onComplete callback
      this.timer = clearInterval(this.timer);
      opt.onStep(1);
      opt.onComplete();
    }
  }
};
</pre>
<p>One very common operation to do with delta is to change the interval [0, 1] of delta to our desired <em>from</em> and <em>to</em> values that we want to compute for our element. A clever thing to do would be to declare this method as a class method for Effect. We'll call it compute:</p>
<pre name="code" class="js:nogutter">
Effect.compute = function(from, to, delta) {
  return from + (to - from) * delta;
};
</pre>
<p>Now If we wanted for example to animate an element's width style from <em>0</em> to <em>10px</em> we could do:</p>
<pre name="code" class="js:nogutter">
var elem = document.getElementById("myElementId"),
    style = elem.style;
var fx = new Effect({
  duration: 500,
  onStep: function(delta) {
    style.width = Effect.compute(0, 10, delta) + 'px';
  }
});
fx.start();
</pre>
<h4>Extending the Effect class</h4>
<p>The animation code defined above could be extended in different ways. For example, this class could be slightly modified to accept a DOM element in its constructor and modify style properties of that element when performing an animation. The code could look like this:</p>
<pre name="code" class="js:nogutter">
var elem = document.getElementById("myElementId");
var fx = new Effect({
  element: elem,
  duration: 1000
});
fx.start({
  'width': [0, 20, 'px'],
  'height': [0, 5, 'em']
});
</pre>
<p>The code would now look more or less like this:</p>
<pre name="code" class="js:nogutter">
//define the class constructor
function Effect(opt) {
  this.opt = {
    element: opt.element,
    duration: opt.duration || 1000,
    fps: opt.fps || 40,
    onComplete: opt.onComplete || function(){}
  };
}

Effect.prototype = {
  //props contains a hash with style properties
  start: function(props) {
    if(this.timer) return;
    var that = this, fps = this.opt.fps;
    this.time = +new Date;
    this.timer = setInterval(function() { that.step(props); },
                             Math.round(1000/fps));
  },
  //triggered at each interval step
  step: function(props) {
     var currentTime = +new Date, time = this.time, opt = this.opt;
     if(currentTime < time + opt.duration) {
      var delta = (currentTime - time) / opt.duration;
     //set the element style properties
     this.setProps(opt.element, props, delta);
    } else {
      this.timer = clearInterval(this.timer);
      this.setProps(opt.element, props, 1);
      opt.onComplete();
    }
  },
  //set style properties. Properties must be
  //in camelcase format.
  setProps: function(elem, props, delta) {
    var style = elem.style;
    for(var prop in props) {
      var values = props[prop];
      style[prop] = Effect.compute(values[0], values[1], delta)
        + (values[2] || '');
    }
  }
};
</pre>
<p>Other extensions might involve normalizing style keywords, adding effect transitions, adding <em>pause</em> <em>resume</em> methods, and/or using more OO JS idioms when coding these classes.</p>
<p>I hope you got to know a little bit more about animation internals and please if you have any advice on this code, which as I told before is just for demonstration, I'll be pleased to hear you!</p>
<img src="http://feeds.feedburner.com/~r/Noumena/~4/CXtc9to58Uw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://blog.thejit.org/2010/03/25/javascript-animations/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://blog.thejit.org/2010/03/25/javascript-animations/</feedburner:origLink></item>
	</channel>
</rss>
