<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>2Paths &#187; graph</title>
	<atom:link href="http://www.2paths.com/tag/graph/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.2paths.com</link>
	<description>Custom Software Technical Architecture, Design and Development in Vancouver, BC, Canada</description>
	<lastBuildDate>Mon, 27 Sep 2010 01:15: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>
			<item>
		<title>Visualizing Semantic Data using Javascript and the HTML Canvas Element</title>
		<link>http://www.2paths.com/2009/06/22/visualizing-semantic-data-using-javascript-and-the-html-canvas-element/</link>
		<comments>http://www.2paths.com/2009/06/22/visualizing-semantic-data-using-javascript-and-the-html-canvas-element/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 21:45:37 +0000</pubDate>
		<dc:creator>gord</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[canvas]]></category>
		<category><![CDATA[graph]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[rdf]]></category>
		<category><![CDATA[semantic]]></category>
		<category><![CDATA[visualization]]></category>

		<guid isPermaLink="false">http://www.2paths.com/?p=1014</guid>
		<description><![CDATA[A work in progress visualization of freedb (RDF version of wikipedia).]]></description>
			<content:encoded><![CDATA[<p>So after trying a few existing javascript/canvas graph visualization libraries, I decided to try my hand at writing my own. We were doing a lot of stuff with RDF in the office at the time, so I decided that my visualization would be a graph of rdf data and relationships. Since I&#8217;d never done anything with the HTML canvas element before, I thought I&#8217;d give that a shot too.</p>
<p><strong>Graph Layout</strong></p>
<p>After looking at various existing graph layout algorithms, I decided to reinvent the wheel and developed my own approach. Each node has a mass based on its size, and I simply used gravity calculations to determine the (inverse, so they repel each other) force each node apples to each other node. You can see this in action when you mouse over a node, it gets bigger and other nodes retreat from it as its mass increases.</p>
<p>This allows each node to position itself in a way so it is visible. It&#8217;s not perfect, but it works okay and makes the graph feel responsive to the user.</p>
<p><strong>How to use it</strong></p>
<p>Double click on a node to load its relationships and related nodes. A node must be an rdf node to load properly, I haven&#8217;t implemented any way to handle normal web links yet. Basically, only click on links that look like <strong>h</strong><strong>ttp://dbpedia.org/resource/<em>something</em><span style="font-weight: normal;">, or that you know are rdf.</span></strong></p>
<div id="attachment_1016" class="wp-caption alignnone" style="width: 521px"><a href="http://staging.2paths.com:8080/deepsnow/" target="_self"><img class="size-full wp-image-1016" src="http://www.2paths.com/wp-content/uploads/2009/06/deepsnow1.png" alt="image of visualization in action, click for demo" width="511" height="300" /></a><p class="wp-caption-text">click for demo of the wikipedia article for baseball</p></div>
<p>If you&#8217;re just interested in the pretty pictures, stop here, if you want more technical information read on.</p>
<p><strong>Implementation</strong></p>
<p>I just used javascript and followed the <a href="http://www.whatwg.org/specs/web-apps/current-work/#canvasrenderingcontext2d" target="_blank">HTML5 docs for using the canvas element</a>. One thing I ran into was the fact that Firefox doesn&#8217;t yet have a full canvas implementation, specifically it doesn&#8217;t yet render text on the canvas. I tried doing some voodoo with absolute positioning divs containing text over the canvas, and after a brief descent into insanity, I found the excellent <a href="http://typeface.neocracy.org/">typeface.js</a> library which emulates the missing canvas calls for text.</p>
<p>As for the javascript code itself, I implemented a simple object graph that can contain vertices or edges, then a render loop just advances the object graph by a given amount of time and renders the scene to the canvas.</p>
<p>The back end serving up rdf was done quickly in grails using the <a href="http://jena.sourceforge.net/" target="_blank">Jena</a> framework to do all the heavy lifting. There is some minimal inference going on using the RDF data to determine if something is an image.</p>
<p><strong><strong>Disclaimer</strong></strong></p>
<p><strong><span style="font-weight: normal;">Keep in mind that this is a work of progress that I have not spent much time with. It has bugs, and it&#8217;s nowhere near usable for anything useful, but it serves its purpose as a proof of concept. I&#8217;m not sure if it will even run under IE, but it should run on any browser that has a decent javascript + canvas implementation.</span></strong></p>
<p><strong> </strong></p>
<p><strong>Conclusions</strong></p>
<p><strong><span style="font-weight: normal;">The canvas element is cool, and works well.</span></strong></p>
<p>Basically I hope you like it. Please leave any suggestions or feedback as comments. I realize it&#8217;s probably full of bugs, but that&#8217;s the nature of the beast.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.2paths.com/2009/06/22/visualizing-semantic-data-using-javascript-and-the-html-canvas-element/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

