<?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>Information Retrieval on the Live Web &#187; Dojo</title>
	<atom:link href="http://livewebir.com/blog/category/dojo/feed/" rel="self" type="application/rss+xml" />
	<link>http://livewebir.com/blog</link>
	<description>by Paul Ogilvie</description>
	<lastBuildDate>Thu, 26 May 2011 18:47:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Dojo charts that sing: box and whisker plots</title>
		<link>http://livewebir.com/blog/2008/11/dojo-charts-that-sing-box-and-whisker-plots/</link>
		<comments>http://livewebir.com/blog/2008/11/dojo-charts-that-sing-box-and-whisker-plots/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 00:01:51 +0000</pubDate>
		<dc:creator>pogil</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Visualization]]></category>

		<guid isPermaLink="false">http://pogil.wordpress.com/?p=19</guid>
		<description><![CDATA[A big part of my job at mSpoke is to understand our users, system performance, and our ability to deliver relevant content.  In order to facilitate this, we&#8217;ve been building a dashboard.  The dashboard is a group of web pages that enables us to easily monitor different aspects of our systems&#8217; status.  I really can&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>A big part of my job at <a title="mSpoke" href="http://www.mspoke.com/">mSpoke</a> is to understand our users, system performance, and our ability to deliver relevant content.  In order to facilitate this, we&#8217;ve been building a dashboard.  The dashboard is a group of web pages that enables us to easily monitor different aspects of our systems&#8217; status.  I really can&#8217;t understate the importance of having the right tools available in order to do data analysis.  Our dashboard is an interactive, frequently updated suite of web pages and graphs that allow us to easily diagnose issues in our system, observe topical trends in live web content, and better understand which content receives our users&#8217; attention.</p>
<p>We use a lot of <a title="The Dojo Toolkit" href="http://dojotoolkit.org/">Dojo</a> at mSpoke, so it was an easy choice for us to use <a title="Dojo Charting" href="http://dojotoolkit.org/projects/dojox#dash-dojox-charts">Dojo Charting</a> to create the plots in our dashboard.  However, it doesn&#8217;t yet include some chart types we&#8217;d like.  So I built them.  This post covers our custom box and whisker plot.</p>
<p>A box and whisker plot elegantly displays distributional statistics about a set of data.  The box covers the middle 50% of the data, the line in the box shows the median, the whiskers cover the range of points that are not outliers, and the outliers are indicated using markers.</p>
<div id="attachment_21" class="wp-caption aligncenter" style="width: 576px"><a href="/charting/boxAndWhisker.html"><img class="size-full wp-image-21" title="Box and whisker plot" src="http://pogil.files.wordpress.com/2008/11/boxandwhisker.png" alt="Dojo box and whisker chart" width="566" height="375" /></a><p class="wp-caption-text">Dojo box and whisker chart</p></div>
<p>I&#8217;ve hosted an <a href="/charting/boxAndWhisker.html">interactive version of the chart and the source code</a>.  mSpoke is happy to share this code, and I would be happy to work with Dojo to include it in later releases. [Update: in 2008 mSpoke placed this code into public domain, with no warranty of any kind. I've updated the source code to reflect this status.]</p>
<h3>Using the box and whisker plot</h3>
<p>Creating a box and whisker plot is very similar to <a title="SitePen Blog: A Beginner's Guide to Dojo Charting, Part 1 of 2" href="http://www.sitepen.com/blog/2008/06/06/a-beginners-guide-to-dojo-charting-part-1-of-2/">the creation of other Dojo charts</a>.  In addition to including dojo.js, you&#8217;ll need to include BoxAndWhisker.js:</p>
<pre>&lt;<span class="start-tag">script</span><span class="attribute-name"> type</span>=<span class="attribute-value">"text/javascript" </span><span class="attribute-name">
        src</span>=<span class="attribute-value">"mspoke/charting/plot2d/BoxAndWhisker.js"</span>&gt;&lt;/<span class="end-tag">script</span>&gt;</pre>
<p>The javascript to create the plot is simple:</p>
<pre>    var chart = new dojox.charting.Chart2D("chart");
    chart.addPlot("default", {type: "BoxAndWhisker", markers: true});</pre>
<p>I&#8217;ve included two different ways to pass in the data for a series.  The first is to simply list all of the data points; BoxAndWhisker.js will compute the median, middle 50% of points, whiskers and outliers.</p>
<pre>    var fill = new dojo.Color([0x00, 0x4f, 0x80, 0.7]);
    var stroke = {color:fill};

    // List all points approach
    chart.addSeries( "Mon",
      [4.4, 6.7, 5.7, 4.6, 4.1, 4.4, 4.3, 4, 3.5, 6.2, 6.5, 0.5],
      {stroke:stroke, fill:fill, center:1, width:0.2});</pre>
<p>You must specify the center and width for the box to display properly.  The center indicates where the x-coordinate the box and whisker for the series will be placed and the width indicates the width along the x-axis of the box.  You can specify the range and labels of the axes using chart.addAxis.  View the source of the interactive version for an example.</p>
<p>The other approach is better suited for handling large data sets, when passing in all of the data would make the script run slowly.  In this case, you need to figure out the box and whisker coordinates yourself.</p>
<pre>    // Pass in box and whisker coordinates and outliers
    chart.addSeries( "Tue",
      {lwhisker: 1.4, lbox: 2.9, median: 3.35, ubox: 5.1, uwhisker: 7.5,
       outliers: [0.2, 8.9]},
      {stroke:stroke, fill:fill , center:2, width:0.2});</pre>
<p>lwhisker and uwhisker are the lower and upper points for the whiskers, lbox and ubox specify the range of the box, and median is the coordinate for the median line in the box.  You can specify the list of markers with the outliers parameter.  Complete source for constructing a box and whisker plot is available in the source of the <a title="Interactive box and whisker chart" href="/charting/boxAndWhisker.html">interactive version</a>.</p>
<h3>Creating custom plot types</h3>
<p>Building a custom Dojo plot isn&#8217;t extremely hard, but it takes some patience to get things just right.  The biggest quirk was that I had indicate in code that the BoxAndWhisker plot type is a part of dojox.charting.  I suspect I may be misunderstanding how to use the Dojo Toolkit correctly.  In order to make the chart visible to Dojo, BoxAndWhisker.js must use dojo.provide at the top of the file:</p>
<pre>dojo.provide("dojox.charting.plot2d.BoxAndWhisker");</pre>
<p>Following the example in other Dojo plots, I used dojo.declare to declare the plot constructur.  As with the call to dojo.provide, I had to declare the plot to be a part of dojox.charting:</p>
<pre>	dojo.declare("dojox.charting.plot2d.BoxAndWhisker",
                          dojox.charting.plot2d.Base, {</pre>
<p>Otherwise, I was able to develop the chart by following the examples already provided in <a href="http://api.dojotoolkit.org/jsdoc/dojox/1.2/dojox.charting.plot2d">dojox.charting.plot2d</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://livewebir.com/blog/2008/11/dojo-charts-that-sing-box-and-whisker-plots/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

