<?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/"
	xmlns:series="http://organizeseries.com/"
	>

<channel>
	<title>SitePen Blog &#187; Dojo</title>
	<atom:link href="http://www.sitepen.com/blog/tag/dojo/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sitepen.com/blog</link>
	<description>SitePen Services and notes about Dojo, Persevere, CometD, JavaScript, and the Web</description>
	<lastBuildDate>Wed, 15 May 2013 22:02:34 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5</generator>
		<item>
		<title>Learning Dojo 1.8</title>
		<link>http://www.sitepen.com/blog/2012/12/06/learning-dojo-1-8/</link>
		<comments>http://www.sitepen.com/blog/2012/12/06/learning-dojo-1-8/#comments</comments>
		<pubDate>Thu, 06 Dec 2012 15:22:57 +0000</pubDate>
		<dc:creator>Mike Wilcox</dc:creator>
				<category><![CDATA[AMD]]></category>
		<category><![CDATA[dgrid]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[featured]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=5904</guid>
		<description><![CDATA[<p>Since we last posted an article on Learning Dojo, things have changed dramatically. Dojo has become an early adopter of AMD, with a new build tool to match; there is a new grid; the documentation has been vastly improved, and there are tutorials galore! In fact, there is so much information out there on learning [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>Since we last posted an article on <a href="http://www.sitepen.com/blog/2010/03/05/learning-dojo/">Learning Dojo</a>, things have changed dramatically. Dojo has become an early adopter of <a href="http://www.sitepen.com/blog/2012/06/25/amd-the-definitive-source/">AMD</a>, with a new build tool to match; there is a <a href="http://www.sitepen.com/blog/2011/10/26/introducing-the-next-grid-dgrid/">new grid</a>; the <a href="http://dojotoolkit.org/reference-guide/1.8/">documentation</a> has been vastly improved, and there are <a href="http://dojotoolkit.org/documentation/">tutorials</a> galore!</p>
<p>In fact, there is so much information out there on learning Dojo, it might be overwhelming. In a way, Dojo 1.7&#8242;s migration to AMD amplifies the problem, in that many previously-published articles no longer reflect the most recent best practices. This post aims to start you off on the right foot by pointing to relevant up-to-date resources for getting started with &mdash; or catching up on &mdash; Dojo 1.8.</p>
<h2>Why Dojo</h2>
<p><a href="http://net.tutsplus.com/tutorials/javascript-ajax/10-reasons-why-your-projects-should-use-the-dojo-toolkit/">10 Reasons your Projects Should use the Dojo Toolkit</a><br />
<a href="http://www.slideshare.net/sitepen/dojo-20-modular-mobile-and-reinventing-web-app-development">Slides: Dojo 2.0: Modular, Mobile, and Reinventing Web App Development</a><br />
<a href="http://net.tutsplus.com/articles/interviews/an-interview-with-dojo-toolkit-creator-dylan-schiemann/">Interview with Dojo Toolkit Co-creator Dylan Schiemann</a></p>
<h2>Getting Started</h2>
<p><a href="http://dojotoolkit.org/documentation/tutorials/1.8/start/">Tutorial: Dojo Start</a> &#8211; Answers many common questions asked by newcomers<br />
<a href="http://dojotoolkit.org/documentation/tutorials/1.8/hello_dojo/">Tutorial: Hello Dojo</a> &#8211; Guides through the first steps in exploring Dojo</p>
<h2>Transitioning from Dojo 1.6</h2>
<p><a href="http://dojotoolkit.org/documentation/tutorials/1.8/modern_dojo/">Tutorial: Modern Dojo</a> &#8211; Explains key differences between Dojo before and after 1.7<br />
<a href="http://www.slideshare.net/jthomas/moving-to-dojo-17-and-the-path-to-20">Slides: Moving to Dojo 1.7 and the path to 2.0</a> &#8211; Presents features new to Dojo 1.7 and up</p>
<h2>AMD Resources</h2>
<p><a href="http://dojotoolkit.org/documentation/tutorials/1.8/modules/">Tutorial: Defining Modules</a> &#8211; Explains how to define and load modules, and configure the loader<br />
<a href="http://www.sitepen.com/blog/2012/06/25/amd-the-definitive-source/">AMD: The Definitive Source</a> &#8211; Explains the reasoning and benefits of AMD<br />
<a href="http://bryanforbes.github.com/amd-commonjs-modules-presentation/2011-10-29/#0">Slides: Modular JavaScript: AMD &#038; CommonJS modules</a> &#8211; Discusses the evolution of AMD<br />
<a href="https://github.com/amdjs/amdjs-api/wiki">AMD API</a> &#8211; Wiki containing AMD API specifications</p>
<h2>Learning Dojo</h2>
<p><a href="http://dojotoolkit.org/documentation/tutorials/1.8/hitch">Tutorial: Making Functions with hitch and partial</a> &#8211; Explains execution context and how to control it<br />
<a href="http://dojotoolkit.org/documentation/tutorials/1.8/declare">Tutorial: Classy JavaScript with dojo/_base/declare</a> &#8211; Explains Dojo&#8217;s chief inheritance mechanism<br />
<a href="http://dojotoolkit.org/documentation/tutorials/1.8/ajax">Tutorial: Ajax with dojo/request</a> &#8211; Introduces Dojo 1.8&#8242;s new Ajax API<br />
<a href="http://dojotoolkit.org/documentation/tutorials/1.8/deferreds/">Tutorial: Getting Started with Deferreds</a> &#8211; Introduces Deferreds, crucial for asynchronous logic<br />
<a href="http://dojotoolkit.org/documentation/tutorials/1.8/promises/">Tutorial: Dojo Deferreds and Promises</a> &#8211; Discusses Promises and their relation to Deferreds<br />
<a href="http://dojotoolkit.org/documentation/tutorials/1.8/intro_dojo_store">Tutorial: Dojo Object Stores</a> &#8211; Explains the dojo/store API, new since Dojo 1.6<br />
<a href="http://dojotoolkit.org/reference-guide/1.8/dojo/">Reference Guide: Dojo</a> &#8211; Index of reference material for the Dojo package</p>
<h2>Learning Dijit</h2>
<p><a href="http://dojotoolkit.org/documentation/tutorials/1.8/understanding_widgetbase">Tutorial: Understanding _WidgetBase</a> &#8211; Details the module forming the basis of all widgets<br />
<a href="http://dojotoolkit.org/documentation/tutorials/1.8/dijit_layout">Tutorial: Layout with Dijit</a> &#8211; Discusses Dijit&#8217;s layout widgets<br />
<a href="http://dojotoolkit.org/documentation/tutorials/1.8/templated">Tutorial: Creating Template-based Widgets</a> &#8211; Describes Dijit&#8217;s templating capabilities<br />
<a href="http://dojotoolkit.org/documentation/tutorials/1.8/recipes/custom_widget">Recipe: Creating a Custom Widget</a> &#8211; Walks through implementing a widget<br />
<a href="http://dojotoolkit.org/reference-guide/1.8/dijit/">Reference Guide: Dijit</a> &#8211; Index of reference material for the Dojo package</p>
<h2>Developing Applications</h2>
<p><a href="http://dojotoolkit.org/documentation/tutorials/1.8/hash">Tutorial: Using dojo/hash and dojo/router</a> &#8211; Discusses Dojo&#8217;s utilities for managing the browser hash<br />
<a href="http://dojotoolkit.org/documentation/tutorials/1.8/recipes/app_controller">Recipe: Application Controller</a> &#8211; enumerates an approach to writing a small app<br />
<a href="https://github.com/csnover/dojo-boilerplate">Dojo Boilerplate</a> &#8211; Provides a starting point for creating a Web application with Dojo<br />
<a href="http://dojotoolkit.org/documentation/tutorials/1.8/mobile/tweetview/getting_started">Tutorial: Getting Started with dojox/mobile</a> &#8211; The first in a series of tutorials to build a mobile app</p>
<h2>Build Tool Resources</h2>
<p><a href="http://dojotoolkit.org/documentation/tutorials/1.8/build">Tutorial: Creating Builds</a> &#8211; Thoroughly explains the various facets of a custom build<br />
<a href="http://www.sitepen.com/blog/2012/08/27/working-with-dojo-and-amd-in-production/">Working with Dojo and AMD in Production</a> &#8211; Enumerates approaches to loading production builds<br />
<a href="http://dojotoolkit.org/reference-guide/1.8/build/index.html">Reference Guide: The Dojo Build System</a> &#8211; Definitive documentation on the new build system<br />
<a href="http://build.dojotoolkit.org/">Dojo Web Builder</a> &#8211; An online tool for creating Dojo builds</p>
<h2>Dojo Packages</h2>
<p><a href="http://www.sitepen.com/blog/2011/07/25/dojo-foundation-packages/">Dojo Foundation Packages</a> &#8211; Explains the role packages play in Dojo&#8217;s future<br />
<a href="http://dgrid.io">dgrid</a> &#8211; Web site for dgrid, a Dojo Foundation package</p>
<h2>Community</h2>
<p>As always, the Dojo community is the best around.  If you get stumped or have an advanced question, you can get more answers by leveraging the following resources:</p>
<ul>
<li><a href="http://www.dojotoolkit.org/community/">Dojo Community</a>, including a forum interface to the dojo-interest mailing list</li>
<li><a href="http://mail.dojotoolkit.org/mailman/listinfo">Mailing Lists</a></li>
<li><a href="http://www.dojotoolkit.org/chat/">Web client for the #dojo IRC channel on irc.freenode.net</a></li>
</ul>
<p>If you find that a self-guided tour or community support is inadequate, SitePen also offers <a href="http://www.sitepen.com/services/training.php">workshops</a> taught by Dojo experts, as well as highly responsive <a href="http://www.sitepen.com/services/support.php">support services</a>.</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/12/06/learning-dojo-1-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dojo Charting: Dive Into Theming</title>
		<link>http://www.sitepen.com/blog/2012/11/09/dojo-charting-dive-into-theming/</link>
		<comments>http://www.sitepen.com/blog/2012/11/09/dojo-charting-dive-into-theming/#comments</comments>
		<pubDate>Fri, 09 Nov 2012 09:00:50 +0000</pubDate>
		<dc:creator>Mike Wilcox</dc:creator>
				<category><![CDATA[Charting]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Vector Graphics]]></category>
		<category><![CDATA[charting]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=5775</guid>
		<description><![CDATA[<p>The previous installment of the Dive Into Dojo series shows how easy it is to Dive Into Dojo Charting. It comes with dozens of stylish themes you can effortlessly plug into any chart. But what if you want your charts to match your website&#8217;s design or business&#8217; branding? No worries: Dojo&#8217;s charting library allows you [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>The previous installment of the Dive Into Dojo series shows how easy it is to <a href="http://www.sitepen.com/blog/2012/11/09/dive-into-dojo-charting-again/">Dive Into Dojo Charting</a>. It comes with dozens of stylish themes you can effortlessly plug into any chart. But what if you want your charts to match your website&#8217;s design or business&#8217; branding? No worries: Dojo&#8217;s charting library allows you to create custom themes!</p>
<p><a href="http://download.dojotoolkit.org/release-1.8.1/dojo-release-1.8.1/dojox/charting/tests/theme_preview.html"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/11/dojo-chart-creation1.jpg" alt="dojo-chart-creation" title="dojo-chart-creation" width="607" height="440" class="alignnone size-full wp-image-5798" /></a></p>
<p><span id="more-5775"></span></p>
<h2>Setting Up Your Namespace</h2>
<p>
	All of Dojo&#8217;s charting themes live with in the <code>dojox/charting/themes</code> namespace. As is the best practice with custom class creation with Dojo, we&#8217;ll create our own namespace for our custom chart themes.  Let&#8217;s give our custom theme the <code>/app/charting/themes/</code> namespace.  <code>/app</code> is a good namespace for most Dojo projects, and I&#8217;ve chosen to mimic the path DojoX uses for themes.
</p>
<pre lang="javascript">
/* create the theme files in the app namespace */
/app/charting/themes/SitePen.js
/app/charting/themes/SitePenFTW.js
</pre>
<h2>Quick Peek at a Simple Theme</h2>
<p>The levels of complexity within Dojo themes can vary greatly depending on your desire to use simply defined colors or implement advanced features like gradations, markers, scrolling, panning, and chart events. Let&#8217;s start by looking at a basic theme called <code>Dollar</code>:</p>
<pre lang="javascript">
define([
	"../SimpleTheme",
	"./common"
], function(SimpleTheme, themes){

	themes.Dollar = new SimpleTheme({
		colors: [
			"#A4CE67",
			"#739363",
			"#6B824A",
			"#343434",
			"#636563"
		]
	});
	return themes.Dollar;
});
</pre>
<p><code>Dollar</code> illustrates how simple creating a theme can be; provide a list of colors and you&#8217;ve created a custom theme!</p>
<h2>Basic Custom Theme: SitePen</h2>
<p>Now that we&#8217;ve seen how simple it is to make a basic theme, we can easily create a custom SitePen theme base on the SitePen logo colors:</p>
<pre lang="javascript">
define([
	"dojox/charting/SimpleTheme",
	"dojox/charting/themes/common"
], function(SimpleTheme, themes){
	
	themes.SitePen = new SimpleTheme({
		colors: [
			"#A4CE67",
			"#739363",
			"#6B824A",
			"#343434",
			"#636563"
		]
	});
	return themes.SitePen;
});
</pre>
<p>Your <code>colors</code> array can have any number of colors.  Colors are repeated in sequence within the chart, if necessary.  Check out a few different charts using the new SitePen theme:</p>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2010/07/SitePenChart1.jpg" alt="Basic Custom Chart Theme" /></p>
<h2>Advanced Chart Theming</h2>
<p>With the basic SitePen chart theme, we simply defined a series of colors we&#8217;d like used in the chart.  With advanced chart theming, you can customize everything from default plotareas, axis, series, and marker colors, fonts, and strokes.  The amount of control you can have over your charts by creating your own theme is truly incredible.  Using Tom Trenka&#8217;s &#8220;Tom&#8221; theme as a template, let&#8217;s make an advanced customization of the SitePen theme in <code>/app/charting/themes/SitePenFTW</code>:</p>
<pre lang="javascript">
define([
	"dojox/charting/Theme",
	"dojox/charting/themes/common",
	"dojox/gfx/gradutils"
], function(Theme, themes){

	var gradient = Theme.generateGradient;

    /* fill settings for gradation */
    defaultFill = {type: "linear", space: "shape", x1: 0, y1: 0, x2: 0, y2: 100};

	/* create theme */
	themes.SitePenFTW = new Theme({

		/* customize the chart wrapper */
		chart: {
			fill: "#333",
			stroke: { color: "#333" },
			pageStyle: {
				backgroundColor: "#000",
				color: "#fff"
			}
		},

		/* plotarea definition */
		plotarea: { fill: "#000" },

		/* axis definition */
		axis:{
			stroke: { // the axis itself
				color: "#fff",
				width: 1
			},
			tick: { // used as a foundation for all ticks
				color: "#fff",
				position: "center",
				font: "normal normal normal 7pt Helvetica, Arial, sans-serif",  // labels on axis
				fontColor: "#fff" // color of labels
			}
		},

		/* series definition */
		series: {
			stroke: { width: 2.5, color: "#fff" },
			outline: null,
			font: "normal normal normal 8pt Helvetica, Arial, sans-serif",
			fontColor: "#fff"
		},

		/* marker definition */
		marker: {
			stroke: { width: 1.25, color: "#fff" },
			outline: { width: 1.25, color: "#fff" },
			font: "normal normal normal 8pt Helvetica, Arial, sans-serif",
			fontColor: "#fff"
		},

		/* series theme with gradations! */
		//light => dark
		//defaultFill object holds all of our gradation settings
		seriesThemes: [
			{ fill: gradient(defaultFill, "#fff", "#f2f2f2") },
			{ fill: gradient(defaultFill, "#d5ecf3", "#bed3d9") },
			{ fill: gradient(defaultFill, "#9ff275", "#7fc25d") },
			{ fill: gradient(defaultFill, "#81ee3b", "#60b32b") },
			{ fill: gradient(defaultFill, "#4dcff4", "#277085") },
			{ fill: gradient(defaultFill, "#666", "#333") }
		],

		/* marker theme */
		markerThemes: [
			{fill: "#bf9e0a", stroke: {color: "#ecc20c"}},
			{fill: "#73b086", stroke: {color: "#95e5af"}},
			{fill: "#216071", stroke: {color: "#277084"}},
			{fill: "#c7212d", stroke: {color: "#ed2835"}},
			{fill: "#87ab41", stroke: {color: "#b6e557"}}
		]
	});

	return themes.SitePenFTW;
});
</pre>
<p>You wont need to define every property created above;  if a given property isn&#8217;t defined, a default value will be used.  On the flip side, you may also override each and any of these settings when creating chart instances.  This custom theme acts as a middle-ground between chart defaults and chart instance settings.</p>
<p>Take a look at some of our enhanced theme examples:</p>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2010/07/SitePenChart2.jpg" alt="Advanced Custom Chart Theme" /></p>
<h2>Using Gradients</h2>
<p>The advanced SitePen theme we created above made use of gradients thanks to the <code>dojox/gfx/gradutils</code> class and the <code>generateGradient()</code> method in<code> dojox/charting/Theme</code>.  Gradation instances can be passed to any property that desires a color (usually the <code>fill</code> property.)  The signature of the <code>generateGradient</code> method is:</p>
<pre lang="javascript">
generateGradient: function(
	fillPattern, 
	colorFrom, 
	colorTo
}
</pre>
<p>The fill pattern holds the gradient settings:</p>
<pre lang="javascript">
{
	type: "linear",		//or "radial"
	space: "shape", 
	x1: 0, 			//gradation direction
	y1: 0, 			//gradation direction
	x2: 0, 			//gradation direction
	y2: 100			//gradation direction
}
</pre>
<p>Feel free to experiment with the gradation settings to find just the right gradient for you. Or use one of the dozens of <a http://download.dojotoolkit.org/release-1.8.1/dojo-release-1.8.1/dojox/charting/tests/theme_preview.html">available Themes</a>. While Dojo&#8217;s charting library comes with a variety of stylish themes, don&#8217;t feel as though you need to choose an existing theme;  take a few minutes to create an eye-catching custom theme to match your branding!</p>
<h2>Further Reading</h2>
<ul>
<li><a href="http://www.sitepen.com/blog/2012/11/09/dive-into-dojo-charting-again/">Dive Into Dojo Charting Again</a></li>
<li><a href="http://www.dojotoolkit.org/reference-guide/1.8/dojox/charting.html#dojox-charting">Dojox Charting Reference Guide</a></li>
<li><a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/">Nightly Charting Tests</a></li>
<li><a href="http://download.dojotoolkit.org/release-1.8.1/dojo-release-1.8.1/dojox/charting/tests/theme_preview.html">Charting Theme Preview</a></li>
<li><a href="http://www.sitepen.com/blog/2012/11/09/a-beginners-guide-to-dojo-charting-with-amd-part-1-of-2/">A Beginner’s Guide to Dojo Charting with AMD, Part 1 of 2</a></li>
<li><a href="http://www.sitepen.com/blog/2012/11/09/a-beginners-guide-to-dojo-charting-with-amd-part-1-of-2/">A Beginner’s Guide to Dojo Charting with AMD, Part 2 of 2</a></li>
<li><a href="http://www.sitepen.com/blog/2012/11/09/zooming-scrolling-and-panning-in-dojo-charting/">Dojo Charting: Zooming, Scrolling, and Panning</a></li>
</ul>
<p></p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/11/09/dojo-charting-dive-into-theming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dive Into Dojo Charting Again</title>
		<link>http://www.sitepen.com/blog/2012/11/09/dive-into-dojo-charting-again/</link>
		<comments>http://www.sitepen.com/blog/2012/11/09/dive-into-dojo-charting-again/#comments</comments>
		<pubDate>Fri, 09 Nov 2012 09:00:46 +0000</pubDate>
		<dc:creator>Mike Wilcox</dc:creator>
				<category><![CDATA[Charting]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Vector Graphics]]></category>
		<category><![CDATA[charting]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=5454</guid>
		<description><![CDATA[<p>One of the most powerful pieces of Dojo is also one of the most underutilized: Charting.  The Dojo Charting library lives within the DojoX (extensions) branch of Dojo, and features numerous chart types, options, and a variety of themes. This post introduce you to the charting library and show you how you can take a [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/header.jpg" alt="header" title="header" width="600" height="287" class="aligncenter size-full wp-image-5456" /></p>
<p>One of the most powerful pieces of Dojo is also one of the most underutilized: Charting.  The Dojo Charting library lives within the DojoX (extensions) branch of Dojo, and features numerous chart types, options, and a variety of themes. This post introduce you to the charting library and show you how you can take a mundane data collection and make it a beautiful visual chart in any modern web browser.</p>
<p><span id="more-5454"></span></p>
<h2>Requiring Charting Classes</h2>
<p>Most of a programmatic Chart is created with chained methods; you rarely will create instances from constructors aside from the Chart itself. However, the underlying code still needs to be required with AMD for the functionality to work. A basic dependency array may look like this:</p>
<pre lang="javascript">
require([
	"dojo/parser",
	"dojox/charting/widget/Chart",
	"dojox/charting/plot2d/Pie",
	"dojox/charting/action2d/Tooltip",
	"dojox/charting/action2d/MoveSlice",
	"dojox/charting/themes/PlotKit/green"
]);
</pre>
<h2>Two Ways to Play</h2>
<p>Much like <a href="http://www.sitepen.com/blog/2010/07/12/dive-into-dijit/">most of the widgets within the Dijit and DojoX libraries</a>, the charting library allows you to create charts programmatically and declaratively.  Let&#8217;s take a look at an example of each approach.</p>
<h3>Declarative Chart Creation</h3>
<p>The declarative method of creating charts is done with HTML markup.  All chart data such as type, axis, plot, and other chart information is created within the chart container.  Here&#8217;s a simple pie chart:</p>
<pre lang="html4strict">
&lt;div data-dojo-type="dojox/charting/widget/Chart" id="chart" style="width:300px; height:300px; margin:10px;"
	data-dojo-props="theme: dojox.charting.themes.PlotKit.green"&gt;
	&lt;div class="plot" name="default" type="Pie" fontColor="#000"&gt;&lt;/div&gt;
	&lt;div class="series" name="A" data="5,8,10,40,20"&gt;&lt;/div&gt;
	&lt;div class="action" type="Tooltip"&gt;&lt;/div&gt;
	&lt;div class="action" type="MoveSlice" shift="2"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>Note that nested chart properties do not yet support HTML5 data-dojo-* attributes, and theme names still use pre-AMD identifiers. These inconsistencies will be resolved in Dojo 1.9.</p>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/pieTip.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/pieTip.png" alt="Pie Chart with Tooltip" title="Pie Chart with Tooltip" width="286" height="284" class="alignnone size-full wp-image-5463" /></a></p>
<h3>Programmatic Chart Creation</h3>
<p>Programmatic chart creation is also quite easy.  The JavaScript code below reproduces the chart above:</p>
<pre lang="javascript">
require([
	"dojox/charting/Chart",
	"dojox/charting/plot2d/Pie",
	"dojox/charting/action2d/Tooltip",
	"dojox/charting/action2d/MoveSlice",
	"dojox/charting/themes/PlotKit/green",
	"dojo/domReady!"
], function(Chart, Pie, Tooltip, MoveSlice, PlotKitGreen){

	var pieChart = new Chart("pieChartNode");
	pieChart.setTheme(PlotKitGreen);
	pieChart.addPlot("default", {
		type: "Pie",
		fontColor: "#000"
	});
	pieChart.addSeries("Series A", [5,8,10,40,20]);
	new MoveSlice(pieChart,"default");
	new Tooltip(pieChart,"default");
	pieChart.render();
});
</pre>
<p>Take a moment to compare the two methods and you will quickly notice how similar the structures are.  It&#8217;s the developer&#8217;s choice which method, declarative or programmatic, to use.  This tutorial will focus on the programmatic method of chart creation though all examples work with both approaches.</p>
<h2>Creating a Simple Chart</h2>
<p>Now that the fundamental pieces of the charting puzzle have been explained, let&#8217;s create a very basic chart.  This chart will depict website visits over 3 months time.  The chart will be a basic StackedAreas chart with different colors to denote the different months.  We&#8217;ll take it step by step.</p>
<p>The first step is to place our data in the format with which the chart works.  The data for our StackedArea chart must hold each value in one array:</p>
<pre lang="javascript">
var json = {
	January: [9420,10126,9803,15965,17290, /* ... */  13165,12390],
	February: [23990,32975,23477,22513,18069, /* ... */ 12956,12815],
	March: [22477,24014,21116,20404,19142, /* ... */ 22077,20263]
};</pre>
<p>The next step is to create the chart programatically.</p>
<pre lang="javascript">
//we have a DIV element with an ID of "chartNode";  that's the argument
var chart = new Chart('chartNode'); </pre>
<p>Then it&#8217;s time to add the plot.</p>
<pre lang="javascript">
//add the default plot
chart.addPlot("default", {
	//type of chart
	type: "StackedAreas",
	//show markers at number points?
	markers: true,
	//curve the lines on the plot?
	tension: "S",
	//show lines?
	lines: true,
	//fill in areas?
	areas: true,
	//offset position for label
	labelOffset: -30,
	//add shadows to lines
	shadows: { dx:2, dy:2, dw:2 }
});</pre>
<p>Since the numbers in this type of chart are significant, we want to add an X axis (representing days) and a Y axis (representing traffic / views).</p>
<pre lang="javascript">
chart.addAxis("x");
chart.addAxis("y", { vertical:true });
</pre>
<p>Now that the frame of the chart has been created, it is time to add the information for each month.  Since we want to fill areas, we&#8217;ll need to pass a stroke and fill color within the series:</p>
<pre lang="javascript">
chart.addSeries("January Visits",json["January"], { stroke: "red", fill: "pink" });
chart.addSeries("February Visits",json["February"], { stroke: "green", fill: "lightgreen" });
chart.addSeries("March Visits",json["March"], { stroke: "blue", fill: "lightblue" });
</pre>
<p>Now that our chart is built and the data is in place, we can render the chart:</p>
<pre lang="javascript">
chart.render();
</pre>
<p>The result is a beautiful chart:</p>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/DWBasicChart.jpg"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/DWBasicChart.jpg" alt="Basic Chart" title="Basic Chart" width="607" height="305" class="alignnone size-full wp-image-5466" /></a></p>
<h2>Chart Animations, Legends, and Extras</h2>
<p>As with every other piece of the Dojo library, the Dojo charting library is flexible enough to incorporate other Dojo classes and widgets.  The basic chart we created above is nice but could use a few useful enhancements.</p>
<h3>Legend</h3>
<p>Adding a legend to the chart is very simple:</p>
<pre lang="javascript">
// get our Legend dependency...
require(["dojox/charting/widget/Legend"], function(Legend) ...
	//this legend is created within an element with a "legendNode" ID.
	new Legend({chart:chart}, 'legendNode');
</pre>
<h3>Chart Animations</h3>
<p>As with basic content on a web page, animation adds some flare and shows focus on an element. Each chart type supports different sets of animations.  To keep it simple, we can add a &#8220;magnify&#8221; animation to the markers on our chart so that the marker grows when the mouse enters it:</p>
<pre lang="javascript">
// get our Magnify dependency...
require(["dojox/charting/action2d/Magnify"], function(Magnify) ...
	//add the magnification animation to our chart for the default plot
	new Magnify({chart:chart}, 'default');
</pre>
<h3>Tooltips</h3>
<p>Our chart features markers at the designated x/y axis numbers but we can enhance those markers with tooltips so that the user can see the exact number the marker represents.</p>
<pre lang="javascript">
var tip = new dojox.charting.action2d.Tooltip(chart1, "default");</pre>
<pre lang="javascript">
// get our Tooltip dependency...
require(["dojox/charting/action2d/Tooltip"], function(Tooltip) ...
	//add the Tooltip to our chart for the default plot
	new Tooltip({chart:chart}, 'default');
</pre>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/DWEnhancedChart.jpg"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/DWEnhancedChart.jpg" alt="Enhanced Chart" title="Enhanced Chart" width="607" height="345" class="alignnone size-full wp-image-5468" /></a></p>
<p>You may also pair Dijit themes with your chart to style the tooltip;  I&#8217;ve added the &#8220;tundra&#8221; theme&#8217;s CSS file to enhance the style of my tooltip.</p>
<h3>Zooming, Scrolling, and Panning</h3>
<p>As you would expect from a vector graphic generation tool, Dojo&#8217;s charting library provides a method by which you may flawlessly zoom in and out on any chart.  You may also accommodate panning and scrolling on your charts.  Read <a href="http://www.sitepen.com/blog/2008/05/15/zooming-scrolling-and-panning-in-dojo-charting/">Zooming, Scrolling, and Panning in Dojo Charting</a> to learn more about these features or <a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_win2d.html">view a great example of panning, scrolling, and zooming!</a></p>
<h2>Chart Events</h2>
<p>Dojo&#8217;s charting library also has its own event connection method: connectToPlot.  This method allows you to add event listeners to your chart and trigger functionality based on the given event.</p>
<pre lang="javascript">
chart1.connectToPlot("default",function(e) {
	
	/* do something */
	
});
</pre>
<p>Chart events provide you a wealth of information, including the type of event, coordinates, plot, shape, and more.  Visit the <a href="http://dojotoolkit.org/reference-guide/1.8/dojox/charting.html#chart-events">Dojo Charting Reference Guide</a> to get detailed information about chart events.</p>
<h2>Chart Themes</h2>
<p>The Dojo charting library provides over 30 themes to make your charts stand out.  You may see a complete list of bundled themes (with preview) in the <a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/theme_preview.html">Dojo Nightly Theme Previewer</a>.  Or visit <a href="http://www.sitepen.com/blog/2010/07/26/dojo-chart-theming/">Dive Into Dojo Chart Theming</a> to learn more.
</p>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/charting-themes.jpg"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/charting-themes.jpg" alt="charting themes" title="charting themes" width="550" height="301" class="alignnone size-full wp-image-5469" /></a></p>
<h2>Chart Families</h2>
<p>This tutorial showed you how to create a basic, but beautiful 2D chart; Dojo&#8217;s charting library has many advanced charting capabilities though.  The different families of Dojo charts includes:
</p>
<ul>
<li>2D Charts: The basic two-dimensional chart.  (<a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_chart2d-amd.html">examples</a>)</li>
<li>3D Charts: Three-dimensional representations of data.  (<a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_bars.html">example</a>)</li>
<li>StoreSeries: Connect to a Dojo Object Store (<a href="http://dojotoolkit.org/documentation/tutorials/1.8/charting_advanced/">tutorial</a>)</li>
</ul>
<h2>New Charting Features</h2>
<p>Dojo introduces new features to the charting library constantly. Some of the more recent additions include:</p>
<ul>
<li>Linear and radial gradients can be used with virtually all chart types (and yes, they work in IE).</li>
<li>Flexible data sourcing via StoreSeries (to work with dojo/store) adds the ability to back charts with practically any sort of data source your would like, even supplying secondary information like tooltips.</li>
<li>Plot and series order manipulations enable one to programmatically shuffle plots and series as needed.</li>
<li>Indirect events that effectively make it possible for linked plots to share events.</li>
<li>External events allow a developer to programmatically generate things like mouseovers and apply them to charting objects.</li>
<li>The default axis is now smarter regarding scaling and sizing.</li>
<li>A new lightweight invisible axis type allows the user to control plot scale and alignment without displaying an axis.</li>
</ul>
<h2>Great Charting Resources</h2>
<ul>
<li><a href="http://dojotoolkit.org/reference-guide/1.8/dojox/charting.html#dojox-charting">Dojox Charting Reference Guide</a></li>
<li><a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/">Nightly Tests</a></li>
<li><a href="http://www.sitepen.com/blog/2012/11/09/a-beginners-guide-to-dojo-charting-with-amd-part-1-of-2/">A Beginner’s Guide to Dojo Charting, Part 1 of 2</a></li>
<li><a href="http://www.sitepen.com/blog/2012/11/09/a-beginners-guide-to-dojo-charting-with-amd-part-2-of-2/">A Beginner’s Guide to Dojo Charting, Part 2 of 2</a></li>
</ul>
<p></p>
<p>The concept of charting can seem difficult, but Dojo&#8217;s charting library is a breeze to dive into!</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/11/09/dive-into-dojo-charting-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dojo Charting: Actions and Tooltips</title>
		<link>http://www.sitepen.com/blog/2012/11/09/dojo-charting-actions-and-tooltips/</link>
		<comments>http://www.sitepen.com/blog/2012/11/09/dojo-charting-actions-and-tooltips/#comments</comments>
		<pubDate>Fri, 09 Nov 2012 09:00:38 +0000</pubDate>
		<dc:creator>Mike Wilcox</dc:creator>
				<category><![CDATA[Charting]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Vector Graphics]]></category>
		<category><![CDATA[charting]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=5699</guid>
		<description><![CDATA[<p>Actions are self-contained objects, which use events to implement certain effects when a user interact with a chart. In general they are designed to attract attention and indicate which charting element is selected, or to show additional information. While you can create your own actions, we took liberty to package some that are generally useful. [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<style>
table.elchart {padding: 1px; border: none; border: 1px solid lightgray;}
table.elchart th {margin: 1px; padding: 3px; border: none; border: 1px solid lightgray; font-weight: bold;}
table.elchart td {margin: 1px; padding: 3px; border: none; border: 1px solid lightgray;}
table.elchart td.highlight {font-weight: bold;}
</style>
<p>Actions are self-contained objects, which use events to implement certain effects when a user interact with a chart. In general they are designed to attract attention and indicate which charting element is selected, or to show additional information.</p>
<p><span id="more-5699"></span></p>
<p>While you can create your own actions, we took liberty to package some that are generally useful. The default library includes these classes: Highlight, Magnify, MoveSlice, Shake, and Tooltip. All of them take advantage of the Dojo animation support. It is best to see them live on <a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_event2d.html">the demo page</a>.</p>
<p>All actions except Tooltip support the following common keyword parameters:</p>
<table class="elchart">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>duration</td>
<td>Number</td>
<td>400</td>
<td>the time of effect in milliseconds.</td>
</tr>
<tr>
<td>easing</td>
<td>Function</td>
<td><code>dojox/fx/easing/elasticOut</code></td>
<td>the easing function that specifies how controlled parameter changes over time.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<h3>Highlight</h3>
<p>This action changes a color of individual elements of a chart when a user hovers over it with the mouse. Affected elements include: markers, columns, bars, circles, and pie slices.</p>
<p>Highlight supports one additional parameter:</p>
<table class="elchart">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>highlight</td>
<td><code>String, dojo/Color</code>, or <code>Function</code></td>
<td>the default highlight function</td>
<td>this parameter defines the highlight color for an individual element.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>The parameter can be any valid value for a color, e.g.,<code> "red", "#FF0000", "#F00", [255, 0, 0], {r: 255, g: 0, b: 0}</code>, and so on. In this case that color will be used to fill an element.</p>
<p>If the parameter is a function, it receives a charting event object (see <a href="http://www.sitepen.com/blog/2012/11/09/dojo-charting-events">Event Support in Dojo Charting</a> for details), and should contain a valid color.</p>
<p>The default highlight function uses special heuristics to select the highlight color. It makes it fully saturated, and light for dark colors, or dark for light colors. In many cases this default is more than adequate. But if you feel a need to implement a custom highlighting scheme, you can easily create your own function.</p>
<p>The picture below demonstrates Highlight (with a constant color) and Tooltip actions.</p>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/11/highlight.png" alt="highlight" title="highlight" width="416" height="222" class="alignnone size-full wp-image-5751" /></p>
<h3>Magnify</h3>
<p>This action magnifies an individual element of a chart, when a user hovers over it with the mouse. Affected elements include markers and circles.</p>
<p>Magnify supports one additional parameter:</p>
<table class="elchart">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>scale</code></td>
<td><code>Number</code></td>
<td>2</td>
<td>the value to scale an element.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>The picture below demonstrates Magnify and Tooltip actions.</p>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/11/magnify.png" alt="" title="magnify" width="394" height="221" class="alignnone size-full wp-image-5752" /></p>
<h3>MoveSlice</h3>
<p>This action moves slices out from a pie chart, when users hover an element with the mouse.</p>
<p>MoveSlice supports the following parameters:</p>
<table class="elchart">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>scale</code></td>
<td><code>Number</code></td>
<td>1.5</td>
<td>the value to scale an element.</td>
</tr>
<tr>
<td><code>shift</code></td>
<td><code>Number</code></td>
<td>7</td>
<td>the value in pixels to move an element from the center.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>The picture below demonstrates MoveSlice, Highlight (with default highlighting parameter), and Tooltip actions.</p>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/11/moveslice.png" alt="moveslice" title="moveslice" width="385" height="331" class="alignnone size-full wp-image-5753" /></p>
<h3>Shake</h3>
<p>This action shakes charting elements, when users hover over an element with the mouse. Affected elements include markers, columns, bars, circles, and pie slices.</p>
<p>Shake supports the following parameters:</p>
<table class="elchart">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>shiftX</code></td>
<td><code>Number</code></td>
<td>3</td>
<td>the maximal value in pixels to move an element horizontally during a shake.</td>
</tr>
<tr>
<td><code>shiftY</code></td>
<td><code>Number</code></td>
<td>3</td>
<td>the maximal value in pixels to move an element vertically during a shake.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>Shake is the highly dynamic effect, so a picture cannot do a justice for it. Please go to <a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_event2d.html">the demo page</a> and see it in action.</p>
<h3>Tooltip</h3>
<p>This action shows a Tooltip, when users hover over a charting element with the mouse. Affected elements include markers, columns, bars, circles, and pie slices.</p>
<p>Tooltip supports the following keyword parameters:</p>
<table class="elchart">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>text</code></td>
<td><code>Function</code></td>
<td>the default text function</td>
<td>the function to produce a Tooltip text.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>The default text function checks if a data point is an object, and uses an optional &#8220;Tooltip&#8221; member if available &mdash; this is a provision for custom Tooltips. Otherwise, it uses a numeric value. Tooltip text can be any valid HTML, so you can specify rich text multi-line Tooltips if desired.</p>
<p>The picture below demonstrates Tooltip, and Highlight actions.</p>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/11/tooltip.png" alt="tooltip" title="tooltip" width="507" height="230" class="alignnone size-full wp-image-5754" /></p>
<h3>Using Actions</h3>
<p>All action objects implement the following methods (no parameters are expected by these methods):</p>
<table class="elchart">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>connect()</code></td>
<td>Connect and start handling events. By default, when an action is created, it is connected. You may need to call fullRender() on your chart object to activate the sending of messages. Typically you create an action object after you define plots, but before the first <code>render()</code> call &mdash; it takes care of everything.</td>
</tr>
<tr>
<td><code>disconnect()</code></td>
<td>Disconnect the event handler. </td>
</tr>
<tr>
<td><code>destroy()</code></td>
<td>Call this method when you want to dispose of your action. It disconnects from its event source and destroys all internal structures, if any, preparing to be garbage-collected.</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>All actions can be constructed like this:</p>
<pre lang="javascript">
require(['dojox/charting/action2d/Magnify'], function(Magnify){
	var action = new Magnify(
		chart1, 
		"default", 
		{
			duration: 200,
			scale: 1.1
		}
	);	
});
</pre>
<p>The first parameter is a chart. The second parameter is the name of a plot. The third parameter is an object (property bag) with all relevant keyword parameters.</p>
<p>An even easier options is to use <code>dojox/charting/widget/Chart</code>. The example below is taken from <a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_widget2d-amd.html">the Dojo Chart widget test</a>:</p>
<pre lang="html4strict">
&lt;div dojotype="dojox/charting/widget/Chart" id="chart"
	 data-dojo-props="theme: dojox.charting.themes.PlotKit.green" style="width: 300px; height: 300px; margin:10px;"&gt;
	&lt;div class="plot" name="default" type="Pie" radius="100" fontcolor="black" labeloffset="-20"&gt;&lt;/div&gt;
	&lt;div class="series" name="A" data="5,8,10,40,20"&gt;&lt;/div&gt;
	&lt;div class="action" type="Tooltip"&gt;&lt;/div&gt;
	&lt;div class="action" type="MoveSlice" shift="2"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>Yes, it is that simple: just define a &lt;div&gt; with the class &#8220;action&#8221; and supply the type. If you want to specify a plot&#8217;s name, use the &#8220;plot&#8221; parameter: <code>plot="Plot1"</code>. By default it will connect to the plot named &#8220;default&#8221;. If you want to change default keyword parameters, just add them to the &lt;div&gt;, e.g., <code>duration="500</code>&#8220;.</p>
<h2>Conclusion</h2>
<p>As you can see you can mixin several actions. In order to avoid unnecessary interference between actions, use your best judgment when selecting them. Try to avoid actions that modify the same visual attributes, like geometry. You can safely mix Tooltip, Highlight, and one geometric action (Magnify, MoveSlice, or Shake).</p>
<h2>Further Reading</h2>
<ul>
<li><a href="http://dojotoolkit.org/documentation/tutorials/1.8/charting/">Dojo Charting Tutorial</a></li>
<li><a href="http://dojotoolkit.org/reference-guide/1.8/dojox/charting.html#dojox-charting">Charting Reference Guide</a></li>
</ul>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/11/09/dojo-charting-actions-and-tooltips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dojo Charting: Zooming, Scrolling, and Panning</title>
		<link>http://www.sitepen.com/blog/2012/11/09/dojo-charting-zooming-scrolling-and-panning/</link>
		<comments>http://www.sitepen.com/blog/2012/11/09/dojo-charting-zooming-scrolling-and-panning/#comments</comments>
		<pubDate>Fri, 09 Nov 2012 09:00:29 +0000</pubDate>
		<dc:creator>Mike Wilcox</dc:creator>
				<category><![CDATA[Charting]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Vector Graphics]]></category>
		<category><![CDATA[charting]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=5681</guid>
		<description><![CDATA[<p>Zooming, scrolling, and panning of charts is a more complex task than than one might expect due to the little-known fact that Dojo Charting can stack multiple plots per chart and can show multiple independent axes on all 4 sides of the chart. These problems were solved with the following API in the chart object: [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>Zooming, scrolling, and panning of charts is a more complex task than than one might expect due to the little-known fact that Dojo Charting can stack multiple plots per chart and can show multiple independent axes on all 4 sides of the chart. These problems were solved with the following API in the chart object:</p>
<p><span id="more-5681"></span></p>
<ul>
<li><strong>chart.setAxisWindow(name, scale, offset)</strong> &mdash; defines a window on the named axis with a scale factor, which starts at the set offset in data coordinates.
<ul>
<li>The <strong>scale</strong> parameter must be &gt;= 1.</li>
<li>The <strong>offset</strong> parameter should be &gt;= 0.</li>
<li>For example if there is an array of 10 numeric values, and 3-8 should show, <strong>chart.setWindow(&#8220;x&#8221;, 3, 2)</strong> will do the trick.</li>
<li>This call affects only plots attached to the named axis, other plots are unaffected.</li>
</ul>
</li>
<li><strong>chart.setWindow(sx, sy, dx, dy)</strong> &mdash; sets scale and offsets on all plots of the chart.</li>
<ul>
<li>The <strong>sx</strong> parameter specifies the magnification factor on horizontal axes. It should be &gt;= 1.</li>
<li>The <strong>sy</strong> parameter specifies the magnification factor on vertical axes. It should be &gt;= 1.</li>
<li>The <strong>dx</strong> parameter specifies the offset of horizontal axes in pixels. It should be &gt;= 0.</li>
<li>The <strong>dy</strong> parameter specifies the offset of vertical axes in pixels. It should be &gt;= 0.</li>
<li>All chart&#8217;s axes (and, by extension, plots) will be affected.</li>
</ul>
</ul>
<p>Obviously these new methods do sanity checks, and don&#8217;t allow you to scroll outside of axis&#8217; boundaries, or zoom out too far.</p>
<p>As you can see these methods are enough to implement arbitrary zooming to drill down to the smallest details of your chart, scrolling, and panning (moving the chart with your mouse in two dimensions). The latter functionality is taxing on old IE, but modern browsers are well up to the task.</p>
<p>Now it is time for some show-and-tell. Below you can see a test chart in its normal state:</p>
<p><a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_win2d.html"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/11/normal.png" alt="normal" title="normal" width="456" height="258" class="alignnone size-full wp-image-5760" /></a></p>
<p>As you can see this chart has four independent axes on all sides, and two plots, each with independent axes: the light brown plot uses the bottom and the the left axis, while the dark brown plot uses the axis on the top and the right sides.</p>
<p>You can access this test application in <a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_win2d.html">Dojo Nightlies</a>. Warning: this link uses the raw Dojo served directly from the development server, so the initial loading will be relatively slow. In real applications you should use Dojo builds.</p>
<p>This is the code required to build this chart:</p>
<pre lang="JavaScript">
require([
	"dojox/charting/Chart",
	"dojox/charting/plot2d/Areas",
	"dojox/charting/plot2d/Grid",
	"dojox/charting/themes/PlotKit/orange",
	"dojox/charting/axis2d/Default",
	"dojo/domReady!"
	],
	function (Chart, Areas, Grid, PlotKitOrange) {
		// Create the chart
		var chart = new Chart("chartNode");

		// set a theme
		chart.setTheme(PlotKitOrange);

		// create the ordinal horizontal axis with custom visual attributes,
		// by default it will be attached to the bottom of the plot area
		chart.addAxis("x", {
			fixLower: "minor", natural: true, stroke: "grey",
			majorTick: {stroke: "black", length: 4},
			minorTick: {stroke: "gray", length: 2}
		});

		// create the ordinal vertical axis with custom visual attributes,
		// by default it will be attached to the left of the plot area
		chart.addAxis("y", {
			vertical: true, min: 0, max: 30,
			majorTickStep: 5, minorTickStep: 1, stroke: "grey",
			majorTick: {stroke: "black", length: 4},
			minorTick: {stroke: "gray", length: 2}
		});

		// add the front plot, which uses default axes (named "x" and "y")
		chart.addPlot("default", {type: "Areas"});

		// add series to the default plot
		chart.addSeries("Series A",
			[0, 25, 5, 20, 10, 15, 5, 20, 0, 25]
		);

		// create the ordinal horizontal axis with custom visual attributes,
		// we specify explicitly that it should be attached to the top
		chart.addAxis("x2", {
			fixLower: "minor", natural: true,
			leftBottom: false, stroke: "grey",
			majorTick: {stroke: "black", length: 4},
			minorTick: {stroke: "gray", length: 2}
		});

		// create the ordinal vertical axis with custom visual attributes,
		// we specify explicitly that it should be attached to the right
		chart.addAxis("y2", {
			vertical: true, min: 0, max: 20,
			leftBottom: false, stroke: "grey",
			majorTick: {stroke: "black", length: 4},
			minorTick: {stroke: "gray", length: 2}
		});

		// create the back plot, which uses our custom axes ("x2" and "y2")
		chart.addPlot("plot2", {
			type: "Areas", hAxis: "x2", vAxis: "y2"
		});

		// add series to "plot2" we just created
		chart.addSeries("Series B",
			[15, 0, 15, 0, 15, 0, 15, 0, 15,
				0, 15, 0, 15, 0, 15, 0, 15],
			{plot: "plot2"}
		);

		// add the bottom of our stack we put the grid
		// that shows major lines, and horizontal minor lines
		chart.addPlot("grid", {type: "Grid", hMinorLines: true});

		// show what we've built
		chart.render();
</pre>
<p>Now let&#8217;s see it magnified by 2 in both dimensions and moved so we can see the peaks in the middle-left part of the chart:</p>
<p><a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_win2d.html"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/11/zoomed.png" alt="zoomed" title="zoomed" width="456" height="258" class="alignnone size-full wp-image-5761" /></a></p>
<p>This picture above was made from the previous picture with one call:</p>
<pre lang="JavaScript">
chart.setWindow(2, 2, 181, 143).render();
</pre>
<p>Obviously axes show new labels to reflect the new state of the chart. Using these labels we can get our bearings and understand what we are seeing.</p>
<p>If we want to return back we can always do:</p>
<pre lang="JavaScript">
chart.setWindow(1, 1, 0, 0).render();
</pre>
<h3>Further Reading</h3>
<ul>
<li><a href="http://dojotoolkit.org/documentation/tutorials/1.8/charting/">Dojo Charting Tutorial</a></li>
<li><a href="http://dojotoolkit.org/reference-guide/1.8/dojox/charting.html#dojox-charting">Charting Reference Guide</a></li>
</ul>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/11/09/dojo-charting-zooming-scrolling-and-panning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Beginner&#8217;s Guide to Dojo Charting with AMD, Part 2 of 2</title>
		<link>http://www.sitepen.com/blog/2012/11/09/a-beginners-guide-to-dojo-charting-with-amd-part-2-of-2/</link>
		<comments>http://www.sitepen.com/blog/2012/11/09/a-beginners-guide-to-dojo-charting-with-amd-part-2-of-2/#comments</comments>
		<pubDate>Fri, 09 Nov 2012 09:00:20 +0000</pubDate>
		<dc:creator>Mike Wilcox</dc:creator>
				<category><![CDATA[Charting]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Vector Graphics]]></category>
		<category><![CDATA[charting]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=5407</guid>
		<description><![CDATA[<p>Part 1of this guide on Dojo Charting covered a basic charting example and the options available in defining our chart type. Now we will examine the options for defining our axes and data sets. Accessing the Axis The addAxis() call on a chart has several options for defining axes. Similar to addPlot(), this call takes [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.sitepen.com/blog/2012/10/29/a-beginners-gu…md-part-1-of-2/">Part 1</a>of this guide on Dojo Charting covered a basic charting example and the options available in defining our chart type.  Now we will examine the options for defining our axes and data sets.</p>
<p><span id="more-5407"></span></p>
<h2>Accessing the Axis</h2>
<p>The <code>addAxis()</code> call on a chart has several options for defining axes.  Similar to <code>addPlot()</code>, this call takes 2 parameters, a name and an options object.  You will need to use &#8220;x&#8221; and &#8220;y&#8221; as your axes names unless you gave them custom names in your <code>addPlot()</code> call.  Additionally, you don&#8217;t have to define the axes if you wish to create charts with one or zero axes, and you can also make charts with more than 2 axes by adding a second plot and attaching axes to it.  Using this approach, you can display up to 4 different axes, 2 vertical and 2 horizontal, using 2 to 4 plots.  Also, a single axis can be shared by more than 1 plot, meaning you could have 2 plots that use the same horizontal axis, but have different vertical axes.  Let&#8217;s look at all the <code>addPlot()</code> options that make this and more possible.</p>
<p>The first option is <code>vertical</code>, which determines if the axis is vertical or horizontal, and defaults to <code>false</code>, which of course means the axis would be horizontal.  Make sure that your alignment matches with values set for <code>hAxis</code> and <code>vAxis</code>, which are &#8220;x&#8221; and &#8220;y&#8221; by default, on your plot or your chart will not render.</p>
<pre lang="javascript">
chart.addPlot("default", {type: "Lines", hAxis: "x", vAxis: "y"});
chart.addAxis("x"); 
chart.addAxis("y", {vertical: true});
</pre>
<p>Next we have the <code>fixUpper</code> and <code>fixLower</code> parameters, which align the ticks and have 4 available options; &#8220;major&#8221;, &#8220;minor&#8221;, &#8220;micro&#8221;, and &#8220;none&#8221;.  These default to &#8220;none&#8221;, and when set will force the end bounds to align to the corresponding tick division.  If &#8220;none&#8221; is chosen, the end bounds will be the highest and lowest values in your data set.  Another related option is the <code>includeZero</code> option, which will make your lower bound be zero instead of the lowest value.  If your lowest data value is negative the <code>includeZero</code> option has no effect.</p>
<pre lang="javascript">  
chart.addAxis("x", {fixUpper: "major", fixLower:"minor"});
chart.addAxis("y", {vertical: true, fixUpper: "major", includeZero: true});
</pre>
<p>Now let&#8217;s examine the <code>leftBottom</code> parameter.  This parameter defaults to <code>true</code>, and along with the <code>vertical</code> parameter, determines the side of the chart in wihch the axis is placed.  At the end of <a href="http://www.sitepen.com/blog/2012/10/29/a-beginners-gu…md-part-1-of-2/">Part 1</a> we examined adding a second plot to our chart.  Let&#8217;s use that sample and give the second plot its own set of axes and anchor them on the top and right using <code>leftBottom</code>.</p>
<pre lang="javascript">
require([
	"dojox/charting/Chart",
	"dojox/charting/plot2d/Lines",
	"dojox/charting/plot2d/Areas",
	"dojox/charting/axis2d/Default",
	"dojo/domReady!"
	],
	function (Chart) {
		var chart = new Chart("simplechart");
		chart.addPlot("default", {type: "Lines"});
		chart.addPlot("someOtherPlot", {type: "Areas", hAxis: "someOtherPlot x", vAxis: "someOtherPlot y"});
		chart.addAxis("x");
		chart.addAxis("y", {vertical: true});
		chart.addAxis("someOtherPlot x", {leftBottom: false});
		chart.addAxis("someOtherPlot y", {vertical: true, leftBottom: false});
		chart.addSeries("Series 1", [1, 2, 2, 3, 4, 5, 5, 7]);
		chart.addSeries("Series 2", [1, 1, 4, 2, 1, 6, 4, 3],
				{plot: "someOtherPlot", stroke: {color:"blue"}, fill: "blue"}
		);
		chart.render();
	});
</pre>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/multiple.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/multiple.png" alt="Multiple Plots" title="Multiple Plots" width="259" height="177" class="alignnone size-full wp-image-5418" /></a></p>
<p>The one thing you may have noticed is that this changes the perspective because the second data set is now charted against a different axis.  You are in luck because you have full control to adjust the axis in almost every way possible.  For example, you can set <code>min</code> and <code>max</code> parameters.</p>
<pre lang="javascript">
chart.addAxis("y", {
        min:1, 
        max:7
});
</pre>
<p>You can turn on and off the tick marks at the minor and micro level, and turn labels on and off for the major and minor levels</p>
<pre lang="javascript">
chart.addAxis("y", {
        majorLabels: true,
        minorTicks: true,
        minorLabels: true,
        microTicks: false
});
</pre>
<p>There&#8217;s <code>natural</code>, which forces all ticks to be on natural numbers, and <code>fixed</code> which will fix the precision on your labels. </p>
<pre lang="javascript">
chart.addAxis("y", {
        natural: false,
        fixed: true 
});
</pre>
<p>If you want you can define the step between the ticks.</p>
<pre lang="javascript">
chart.addAxis("y", {
        majorTickStep: 4,
        minorTickStep: 2,
        microTickStep: 1
});
</pre>
<p>You can control the color of the axis, the color and length of your tick marks, and the font and color of your labels.</p>
<pre lang="javascript">
var chart = new Chart("simplechart");
chart.addPlot("default", {type: "Lines"});
chart.addPlot("someOtherPlot", {type: "Areas", hAxis: "someOtherPlot x", vAxis: "someOtherPlot y"});
chart.addAxis("x");
chart.addAxis("y", {vertical: true, leftBottom: true});
chart.addAxis("someOtherPlot x", {leftBottom: false});
chart.addAxis("someOtherPlot y", {
	vertical: true,
	leftBottom: false,
	max: 7,
	stroke: "green",
	font: "normal normal bold 14pt Tahoma",
	fontColor: "red",
	majorTick: {color: "red", length: 6},
	minorTick: {stroke: "black", length: 3}
});
chart.addSeries("Series 1", [1, 2, 2, 3, 4, 5, 5, 7]);
chart.addSeries("Series 2", [1, 1, 4, 2, 1, 6, 4, 3],
		{plot: "someOtherPlot", stroke: {color:"red"}, fill: "blue"}
);
chart.render();
</pre>
<p>When added to our previous example, the result is:</p>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/styledAxis.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/styledAxis.png" alt="Styled Axis" title="Styled Axis" width="245" height="176" class="alignnone size-full wp-image-5427" /></a></p>
<p>You can also add a grid at your tick marks to your entire chart by adding a Grid plot.  The grid plot allows you to turn the grid on and off for major and minor ticks in both directions, and you can assign axes names if you have multiple axes.  Let&#8217;s add a grid to the other axes in our above example. Insert the following code somewhere before <code>render()</code>.</p>
<pre lang="javascript">
chart.addPlot("gridPlot", {type: "Grid",
	hAxis: "someOtherPlot x",
	vAxis: "someOtherPlot y",
	hMajorLines: true,
	hMinorLines: false,
	vMajorLines: true,
	vMinorLines: false
});
</pre>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/grid.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/grid.png" alt="Grid Plot" title="Grid Plot" width="250" height="175" class="alignnone size-full wp-image-5431" /></a></p>
<p>Last but not least, you have the ability to assign custom labels to your axis.  Make sure to allow sufficient space in your div for the text to display properly.  Here is an example using abbreviated month names with a Columns plot.</p>
<pre lang="javascript">
var chart = new Chart("simplechart");
chart.addPlot("default", {type: "Columns", gap:2});
chart.addAxis("x", {
	labels: [
		{value: 1, text: "Jan"}, {value: 2, text: "Feb"},
		{value: 3, text: "Mar"}, {value: 4, text: "Apr"},
		{value: 5, text: "May"}, {value: 6, text: "Jun"},
		{value: 7, text: "Jul"}, {value: 8, text: "Aug"},
		{value: 9, text: "Sep"}, {value: 10, text: "Oct"},
		{value: 11, text: "Nov"}, {value: 12, text: "Dec"}]
	});
chart.addAxis("y", {vertical: true, leftBottom: true, min:1});
chart.addSeries("Series 1", [3, 2, 2, 3, 4, 5, 5, 7, 10, 2, 3, 14],
	{plot: "default", stroke: {color:"#466C89"}, fill: "#00E9FF"});
chart.render();
</pre>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/columns.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/columns.png" alt="columns" title="columns" width="355" height="230" class="alignnone size-full wp-image-5443" /></a></p>
<h2>Data, it&#8217;s Series(ous) Business</h2>
<p>Finally, we get to <code>addSeries()</code>, where we define the data sets that will be displayed on our chart. <code>addSeries()</code> accepts 3 parameters, a name, a data array and an options object.  There is also an <code>updateSeries()</code> call that takes a name and data array for when you want to refresh your data.  Let&#8217;s run through the parameters available in the <code>addSeries()</code> call, then look at the data array.</p>
<p>There are only a few parameters to cover for the <code>addSeries()</code> call.  First up is <code>stroke</code>, which covers the color and width of your line or the border of your bar and column type graphs. Along with <code>stroke</code> we have <code>fill</code>, and it determines the color under the line in Areas type line graphs and determines the bar fill color for Bar and Column type graphs.  If you are familiar with SVG or dojox.gfx, <code>stroke</code> and <code>fill</code> should be very familiar.</p>
<pre lang="javascript">
chart.addSeries(
	"Series 1", 
	[1, 2, 4, 5, 5, 7], 
	{stroke: {color: "red", width: 2}, fill: "blue"}
);
</pre>
<p>The other option is <code>marker</code> and it allows you to define custom markers using SVG path segments.  Here are the marker types as defined in <code>dojox/charting/SimpleTheme</code>.  Note that each is just defined internally as an SVG path:</p>
<pre lang="javascript">
CIRCLE:		"m-3,0 c0,-4 6,-4 6,0 m-6,0 c0,4 6,4 6,0", 
SQUARE:		"m-3,-3 l0,6 6,0 0,-6 z", 
DIAMOND:	"m0,-3 l3,3 -3,3 -3,-3 z", 
CROSS:		"m0,-3 l0,6 m-3,-3 l6,0", 
X:		"m-3,-3 l6,6 m0,-6 l-6,6", 
TRIANGLE:	"m-3,3 l3,-6 3,6 z", 
TRIANGLE_INVERTED:"m-3,-3 l3,6 3,-6 z"
</pre>
<p>The marker style is handled by the theme you choose for your chart. However, if you did wish to add custom markers, you might do something like this:</p>
<pre lang="javascript">
chart.addSeries("Series 1", [1, 2, 2, 3, 4, 5, 5, 7], {
		stroke: { color: "purple", width: 2 },
		fill: "yellow",
		marker: "m0,-5 l5,5 -5,5 -5,-5 z"
	}
);
chart.addSeries("Series 2", [1, 1, 4, 2, 1, 6, 4, 3],{
		plot: "someOtherPlot",
		stroke: {color:"#FFA100", width:1},
		fill: "blue",
		marker: (new SimpleTheme()).markers.TRIANGLE_INVERTED
	}
);
</pre>
<p>Now take a look at these options in action using our above example:</p>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/markers.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/markers.png" alt="markers" title="markers" width="251" height="173" class="alignnone size-full wp-image-5448" /></a></p>
<p>The only thing we have left is the data array, and it&#8217;s just that, an array of data.  All plot types can accept a one dimensional array, but there are some additional format options available based on the type of chart. With a 1 dimensional array for Line type graphs the X axis will be integers; <em>[1,2,3...]</em>  and the data will be the Y axis.  For Bar type plots the data is the length of the bar and the choice between Column or Bar type determines the orientation.  And for Pie type charts the sum of the array is your whole pie.  All the plot types except Pie can have multiple series.   </p>
<pre lang="javascript">
chart.addSeries("Series A", [1, 2, 3, 4, 5]);
</pre>
<p>For any non-stacked Line plot type you can specify coordinate pairs.   You need to use keys that correspond to the <code>hAxis</code> and <code>vAxis</code> parameters defined in the <code>addPlot()</code> call.  These default to <code>x</code> and <code>y</code>.</p>
<pre lang="javascript">
chart.addSeries("Series A", 
	[{x: 1, y: 5}, {x: 1.5, y: 1.7}, {x: 2, y: 9}, {x: 5, y: 3}]);
chart.addSeries("Series B", 
	[{x: 3, y: 8.5}, {x: 4.2, y: 6}, {x: 5.4, y: 2}]);
</pre>
<p>Here is an example of using coordinate pairs with a Scatter plot:</p>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/scatter.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/scatter.png" alt="scatter" title="scatter" width="298" height="198" class="alignnone size-full wp-image-5449" /></a></p>
<p>With any of the stacked plot types each data set added with <code>addSeries()</code> is placed relative to the previous set.  Here is a simple example that shows this concept.  Instead of the second data set being a straight line across at 1, all the points are 1 above the point from the first data set.</p>
<pre lang="javascript">
chart.addPlot("default", {type:'Stacked'});
chart.addSeries("Series 1", [1, 2, 3, 4, 3]);
chart.addSeries("Series 2", [1, 1, 1, 1, 1], {stroke: {color: "red"}});
</pre>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/StackedLine.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/StackedLine.png" alt="" title="StackedLine" width="309" height="201" class="alignnone size-full wp-image-5450" /></a></p>
<p>For Pie type charts you can specify additional information: the text label for each slice, the color of the slice and even a font color that overrides the font color definable in the <code>addPlot()</code> call.</p>
<pre lang="javascript">
chart.addPlot("default", {type:'Pie'});
chart.addSeries("Series A", [
	{y: 4, color: "#FFDBDB"},
	{y: 2, color: "#D0F2D2"},
	{y: 1, color: "#DBF1FF"},
	{y: 1, text: "Other", color: "white", fontColor: "red", size:14}
]);
chart.render();
</pre>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/pie.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/pie.png" alt="pie" title="pie" width="247" height="235" class="alignnone size-full wp-image-5451" /></a></p>
<h2>Charting your own course</h2>
<p>That&#8217;s it!  You now know all the basics of Dojo Charting.  Congratulations! If you are wondering where to go from here, you will want to check out charting themes.  They are simple to use with your charts by just calling <code>setTheme()</code>.  There are dozens available and pretty straight forward if you want to make your own.</p>
<pre lang="javascript">
require([
	"dojox/charting/Chart",
	"dojox/charting/plot2d/Columns",
	"dojox/charting/themes/PlotKit/blue",
	"dojox/charting/axis2d/Default",
	"dojo/domReady!"
	],
	function (Chart, Columns, PlotKitBlue) {
		var chart = new Chart("simplechart");
		chart.addPlot("default", {type: Columns, gap:2});
		chart.addAxis("x");
		chart.addAxis("y", {vertical: true, min:1});
		chart.addSeries("Series 1", [3, 2, 2, 3, 4, 5, 5, 7, 10, 2, 3, 14]);
		chart.setTheme(PlotKitBlue);
		chart.render();
	});
</pre>
<p>You&#8217;ll also want to check out the <a href="http://dojotoolkit.org/documentation/tutorials/1.8/charting_advanced/">Advanced Charting</a> tutorial to learn more about Charting, as well as our charting blog posts on <a href="http://www.sitepen.com/blog/2012/11/09/dojo-charting-zooming-scrolling-and-panning">zomming, scrolling and panning</a>, <a href="http://www.sitepen.com/blog/2012/11/09/dojo-charting-events">events</a> and <a href="http://www.sitepen.com/blog/2012/11/09/dojo-charting-actions-and-tooltips">actions and tooltips</a> <a href="http://www.sitepen.com/blog/2012/11/09/dojo-charting-dive-into-theming">themes</a>, and <a href="http://www.sitepen.com/blog/2012/11/09/dojo-charting-legends">legends</a>.</p>
<p>Have fun!</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/11/09/a-beginners-guide-to-dojo-charting-with-amd-part-2-of-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dojo Charting: Legends</title>
		<link>http://www.sitepen.com/blog/2012/11/09/dojo-charting-legends/</link>
		<comments>http://www.sitepen.com/blog/2012/11/09/dojo-charting-legends/#comments</comments>
		<pubDate>Fri, 09 Nov 2012 09:00:18 +0000</pubDate>
		<dc:creator>Mike Wilcox</dc:creator>
				<category><![CDATA[Charting]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Vector Graphics]]></category>
		<category><![CDATA[charting]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=5744</guid>
		<description><![CDATA[<p>Legend The Legend widget is one of the most popular features in Dojo charting. This widget was contributed by Chris Mitchell of IBM. It can handle all existing chart and plot types and supports horizontal and vertical modes. By default it uses the &#8220;legend&#8221; parameter of a series. It reverts to the &#8220;name&#8221; parameter if [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<h2>Legend</h2>
<p>The Legend widget is one of the most popular features in Dojo charting. This widget was contributed by Chris Mitchell of IBM. It can handle all existing chart and plot types and supports horizontal and vertical modes.</p>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/11/legend.png" alt="legend" title="legend" width="580" height="599" class="alignnone size-full wp-image-5765" /></p>
<p>By default it uses the &#8220;legend&#8221; parameter of a series. It reverts to the &#8220;name&#8221; parameter if legend is not specified.</p>
<p>For a pie chart, the behavior is different: if the chart was specified with an array of numbers, it will use numbers. Otherwise it will check object properties in the following order: &#8220;legend&#8221;, &#8220;text&#8221;, and the numeric value.</p>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/11/legend2.png" alt="legend2" title="legend2" width="580" height="599" class="alignnone size-full wp-image-5766" /></p>
<p>The legend icons will change if you have more than one series. This is especially evident in Marker charts:</p>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/11/markers.png" alt="markers" title="markers" width="280" height="312" class="alignnone size-full wp-image-5767" /></p>
<p>Legends can be created programmatically as well. Just pass in the chart object instead of the chart id. The following code makes the Marker chart shown above:</p>
<pre lang="javascript">
require([
	"dojox/charting/Chart",
	"dojox/charting/widget/Legend",
	"dojox/charting/plot2d/Markers",
	"dojox/charting/themes/PlotKit/green"
], function(Chart, Legend, Markers, PlotKitGreen){

	var chart = new Chart("chartNode");
	chart.setTheme(PlotKitGreen);
	chart.addPlot("default", {type: "Markers"});
	chart.addSeries("Series A", [2.6, 1.8, 2, 1, 1.4, 0.7, 2]);
	chart.addSeries("Series B", [5.6, 1, 9, 11, 4.4, 8.7, 2]);
	chart.addSeries("Series C", [8.6, 6, 3, 6, 8, 6, 6]);
	chart.render();

	new Legend({chartRef:chart}, 'legendNode');
});
</pre>
<h3>Further Reading</h3>
<ul>
<li><a href="http://dojotoolkit.org/documentation/tutorials/1.8/charting/">Dojo Charting Tutorial</a></li>
<li><a href="http://dojotoolkit.org/reference-guide/1.8/dojox/charting.html#dojox-charting">Charting Reference Guide</a></li>
</ul>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/11/09/dojo-charting-legends/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dojo Charting: Events</title>
		<link>http://www.sitepen.com/blog/2012/11/09/dojo-charting-events/</link>
		<comments>http://www.sitepen.com/blog/2012/11/09/dojo-charting-events/#comments</comments>
		<pubDate>Fri, 09 Nov 2012 09:00:17 +0000</pubDate>
		<dc:creator>Mike Wilcox</dc:creator>
				<category><![CDATA[Charting]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Vector Graphics]]></category>
		<category><![CDATA[charting]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=5685</guid>
		<description><![CDATA[<p>Chart events allow you to attach behavior in response to user actions to various chart features, such as markers, bars, columns, or pie wedges. You can interact with following elements representing your data points: Chart Element Comment Default marker This chart is responsible for lines and areas with markers, and the scatter chart. Stacked marker [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>
Chart events allow you to attach behavior in response to user actions to various chart features, such as markers, bars, columns, or pie wedges. You can interact with following elements representing your data points:</p>
<p><span id="more-5685"></span></p>
<style>
table.elchart { border: none; border: 1px solid lightgray;}
table.elchart th {padding: 3px; margin: 1px; border: none; border: 1px solid lightgray; font-weight: bold;}
table.elchart td {padding: 3px; margin: 1px; border: none; border: 1px solid lightgray;}
table.elchart td.highlight {font-weight: bold;}
</style>
<table class="elchart">
<thead>
<tr>
<th>Chart</th>
<th>Element</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td>Default</td>
<td>marker</td>
<td>This chart is responsible for lines and areas with markers, and the scatter chart.</td>
</tr>
<tr>
<td>Stacked</td>
<td>marker</td>
<td>This chart is responsible for stacked lines and areas.</td>
</tr>
<tr>
<td>Bars</td>
<td>bar</td>
<td>Horizontal bars.</td>
</tr>
<tr>
<td>StackedBars</td>
<td>bar</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>ClusteredBars</td>
<td>bar</td>
<td>A clustered version of bars.</td>
</tr>
<tr>
<td>Columns</td>
<td>column</td>
<td>Vertical columns.</td>
</tr>
<tr>
<td>StackedColumns</td>
<td>column</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>ClusteredColumns</td>
<td>column</td>
<td>A clustered version of columns.</td>
</tr>
<tr>
<td>Bubble</td>
<td>circle</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>Pie</td>
<td>slice</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<p>The Following events are supported: <strong><code>onclick</code></strong>, <strong><code>onmouseover</code></strong>, and <strong><code>onmouseout</code></strong>.</p>
<p>Users can attach event handlers to individual plots of a chart with the <code>connectToPlot()</code> method, which accepts three arguments:</p>
<pre lang="JavaScript">
chart.connectToPlot(
    plotName,    // the unique plot name you specified when creating a plot
    object,      // both object and method are the same used by dojo.connect()
    method       // you can supply a function without an object
);
</pre>
<p>The event handler receives one argument. While it tries to unify information for different charts, its exact layout depends on the chart type:</p>
<table class="elchart">
<thead>
<tr>
<th>Attribute</th>
<th>Expected Value</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="highlight">type</td>
<td>&#8220;onclick&#8221;, &#8220;onmouseover&#8221;, or &#8220;onmouseout&#8221;</td>
<td>Use this attribute to differentiate between different types of events.</td>
</tr>
<tr>
<td class="highlight">element</td>
<td>&#8220;marker&#8221;, &#8220;bar&#8221;, &#8220;column&#8221;, &#8220;circle&#8221;, or &#8220;slice&#8221;</td>
<td>Indicates what kind of element has sent the event. Can be used to define highlighting or animation strategies. For details consult the previous table.</td>
</tr>
<tr>
<td class="highlight">x</td>
<td>number</td>
<td>The &#8220;x&#8221; value of the point. Can be derived from the index (depends on a chart).</td>
</tr>
<tr>
<td class="highlight">y</td>
<td>number</td>
<td>The &#8220;y&#8221; value of the point. Can be derived from the index (e.g., for a bar chart).</td>
</tr>
<tr>
<td class="highlight">index</td>
<td>number</td>
<td>The index of a data point that caused the event.</td>
</tr>
<tr>
<td class="highlight">run</td>
<td>object</td>
<td>The data run object that represents a data series. Example: o.run.data[o.index] &mdash; returns the original data point value for the event (o is an event handler&#8217;s argument).</td>
</tr>
<tr>
<td class="highlight">plot</td>
<td>object</td>
<td>The plot object that hosts the event&#8217;s data point.</td>
</tr>
<tr>
<td class="highlight">hAxis</td>
<td>object</td>
<td>The axis object that is used as a horizontal axis by the plot.</td>
</tr>
<tr>
<td class="highlight">vAxis</td>
<td>object</td>
<td>The axis object that is used as a vertical axis by the plot.</td>
</tr>
<tr>
<td class="highlight">event</td>
<td>object</td>
<td>The original mouse event that started the event processing.</td>
</tr>
<tr>
<td class="highlight">shape</td>
<td>object</td>
<td>The gfx shape object that represents a data point.</td>
</tr>
<tr>
<td class="highlight">outline</td>
<td>object</td>
<td>The gfx shape object that represents an outline (a cosmetic shape). Can be null or undefined.</td>
</tr>
<tr>
<td class="highlight">shadow</td>
<td>object</td>
<td>The gfx shape object that represents a shadow (a cosmetic shape). Can be null or undefined.</td>
</tr>
<tr>
<td class="highlight">cx</td>
<td>number</td>
<td>The &#8220;x&#8221; component of the visual center of a shape in pixels. Supplied only for &#8220;marker&#8221;, &#8220;circle&#8221;, and &#8220;slice&#8221; elements. Undefined for all other elements.</td>
</tr>
<tr>
<td class="highlight">cy</td>
<td>number</td>
<td>The &#8220;y&#8221; component of the visual center of a shape in pixels. Supplied only for &#8220;marker&#8221;, &#8220;circle&#8221;, and &#8220;slice&#8221; elements. Undefined for all other elements.</td>
</tr>
<tr>
<td class="highlight">cr</td>
<td>number</td>
<td>The radius in pixels of a &#8220;circle&#8221;, or a &#8220;slice&#8221; element. Undefined for all other elements.</td>
</tr>
</tbody>
</table>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/11/alert.png" alt="" title="alert" width="548" height="356" class="alignnone size-full wp-image-5757" /></p>
<p>And finally it is time to see it in action: <a href="http://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/charting/tests/test_event2d.html">the event demo</a> straight from the Dojo nightly. Hover over markers, bars, columns, bubbles, and pie slices, and click on them as well.</p>
<p>Besides dojox.charting, the demo illustrates some other parts of Dojo as well:
<ul>
<li><strong>dojo/fx</strong> &mdash; the Dojo Core animation toolkit for creating and combining animations.
<ul>
<li><strong>dojox/fx/easing</strong> &mdash; a collection of easing functions to spice up visual effects.</li>
<li><strong>dojox/gfx/fx</strong> &mdash; 2D graphics-specific animation helpers.</li>
</ul>
</li>
<li><strong>dojox/lang/functional</strong> &mdash; power of functional programming at your fingertips.</li>
</ul>
<p>All of these components make it possible to code up the demo rather quickly &mdash; the modular nature of Dojo pays off.</p>
<h3>Further Reading</h3>
<ul>
<li><a href="http://dojotoolkit.org/documentation/tutorials/1.8/charting/">Dojo Charting Tutorial</a></li>
<li><a href="http://dojotoolkit.org/reference-guide/1.8/dojox/charting.html#dojox-charting">Charting Reference Guide</a></li>
</ul>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/11/09/dojo-charting-events/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Beginner&#8217;s Guide to Dojo Charting with AMD, Part 1 of 2</title>
		<link>http://www.sitepen.com/blog/2012/11/09/a-beginners-guide-to-dojo-charting-with-amd-part-1-of-2/</link>
		<comments>http://www.sitepen.com/blog/2012/11/09/a-beginners-guide-to-dojo-charting-with-amd-part-1-of-2/#comments</comments>
		<pubDate>Fri, 09 Nov 2012 09:00:01 +0000</pubDate>
		<dc:creator>Mike Wilcox</dc:creator>
				<category><![CDATA[Charting]]></category>
		<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Vector Graphics]]></category>
		<category><![CDATA[charting]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=5373</guid>
		<description><![CDATA[<p>Welcome! If you are looking for a way to quickly and easily add great looking and functional charts and graphs to your web pages, you&#8217;ve found the right place. All you need is a tiny bit of JavaScript skills and a copy of Dojo. In this two part guide, we look at how easy it [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>Welcome!  If you are looking for a way to quickly and easily add great looking and functional charts and graphs to your web pages, you&#8217;ve found the right place.  All you need is a tiny bit of JavaScript skills and a copy of <a href="http://www.dojotoolkit.org/">Dojo</a>.</p>
<p>In this two part guide, we look at how easy it is to get Dojo Charting up and running with version 1.8, and then examine in greater detail the options available for different looks for your charts.  Today in Part 1, we start with a basic example and then examine all the options available in defining your plot type.  Part 2 will cover the options available in defining the axes and data sets for your charts.</p>
<p><span id="more-5373"></span></p>
<p>Let&#8217;s get started.  Here is the code for a basic Dojo Chart, with the minimum modules that need to be required. Make sure you have the proper path to your dojo.js file:</p>
<pre lang="html">
&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;Chart&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id="simplechart" style="width: 250px; height: 150px;"&gt;&lt;/div&gt;
    &lt;script src='../../dojo/dojo.js' data-dojo-config="async:true"&gt;&lt;/script&gt;
    &lt;script&gt;
		require([
			"dojox/charting/Chart",
			"dojox/charting/plot2d/Lines",
			"dojox/charting/axis2d/Default",
			"dojo/domReady!"
			],
				function (Chart) {
					var chart = new Chart("simplechart");
					chart.addPlot("default", {type: "Lines"});
					chart.addAxis("x");
					chart.addAxis("y", {vertical: true});
					chart.addSeries("Series 1", [1, 2, 2, 3, 4, 5, 5, 7]);
					chart.render();
                });
    &lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>This source code produces the following simple chart.</p>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/simple.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/simple.png" alt="Simple Chart" title="simple" class="alignnone size-full wp-image-5376" /></a></p>
<p>Looking at this we can see that most of the work in defining the chart is done in the <code>addPlot()</code>, <code>addAxis()</code>, and <code>addSeries()</code> functions.  Today we will examine the <code>addPlot()</code> call, and Part 2 will cover the options for <code>addAxis()</code> and <code>addSeries()</code>.</p>
<h2>Got Plot?</h2>
<p>The <code>addPlot()</code> call determines what type of chart you are going to produce, and there are a variety of options to select.  Here are a few examples:</p>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/tutorial_types.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/tutorial_types.png" alt="Tutorial Types" title="Tutorial Types" class="alignnone size-full wp-image-5378" /></a></p>
<p><code>addPlot()</code> accepts 2 arguments, a <code>name</code> and an <code>options</code> object.  The <code>name</code> is important if you want to have more than 1 plot type on your chart, a concept we will cover shortly.  The <code>options</code> object may vary depending on the type of plot you use.  Note that your choice of plot type may define appropriate default options.</p>
<p><code>type</code> is the main option, and the default value is a basic line chart, but it doesn&#8217;t hurt to indicate it anyway so that for other developers (or future-you) your intentions are clear:</p>
<pre lang="javascript">
chart.addPlot("default", {type: "Lines"});
</pre>
<p>Available 2D chart types include: </p>
<ul>
<li>Areas &#8211; Area under data line(s) will be filled</li>
<li>Bars &#8211; Horizontal bars. </li>
<li>ClusteredBars &#8211; Horizontal bars with clustered data sets</li>
<li>ClusteredColumns &#8211; Vertical bars with clustered data sets</li>
<li>Columns &#8211; Vertical bars</li>
<li>Grid &#8211; For adding a grid layer to you chart</li>
<li>Lines &#8211; Basic line chart</li>
<li>Markers &#8211; Lines with markers</li>
<li>MarkersOnly &#8211; Markers, sans lines</li>
<li>Pie &#8211; Goes great with punch!</li>
<li>Scatter &#8211; Cooler name for MarkersOnly </li>
<li>Stacked &#8211; Data sets charted in relation to the previous data set. </li>
<li>StackedAreas &#8211; Stacked data sets with filled areas under chart lines</li>
<li>StackedBars &#8211; Stacked data sets with horizontal bars </li>
<li>StackedColumns &#8211; Stacked data sets with vertical bars</li>
<li>StackedLines &#8211; Stacked data sets using lines</li>
</ul>
<p>A basic line-type chart includes Lines, Areas or Markers and have 5 specific options including, strangely enough, <code>lines</code>, <code>areas</code>, and <code>markers</code>.  These are often defined by the plot type you choose, but can be changed to get your desired behavior.  The <code>lines</code> option determines whether or not lines are used to connect your data points.  If the <code>areas</code> type is selected, the area below your data line will be filled.  The <code>markers</code> option will determine if markers are placed at your data points.</p>
<pre lang="javascript">
chart.addPlot("default", {type: "StackedAreas", lines: true, areas: true, 
	markers: false});
</pre>
<p>There are also 2 graphical options, <code>tension</code> and <code>shadows</code>.  <code>tension</code> allows you to add some curve to the lines on your plot.  By default this option is set to 0 which is off.  I found 2-4 to be a good range for natural looking curves.  For some crazy effects try setting this to values < 1 or negatives.  <code>shadows</code> allow you to add a shadow effect, and consists of an object of 3 parameters, <code>dx</code>, <code>dy</code> and <code>dw</code>, which represent the offset to the right, the offset down, and the width of the shadow line, respectively.  You can use negative values for your <code>dx</code> and <code>dy</code> parameters to produce a shadow that is to the left or above your chart line.</p>
<pre lang="javascript">
chart.addPlot("default", {type: "StackedLines",tension:3, 
	shadows: {dx: 2, dy: 2, dw: 2}});
</pre>
<p>Bar and Column graph types have 1 unique option: they will accept a <code>gap</code> parameter that determines the spacing between your bars or columns in pixels.</p>
<pre lang="javascript">
chart.addPlot("default", {type: "Bars", gap: 5});
</pre>
<p>For any chart type that supports axes, you can also define custom names to your axes here. By default they are "x" and "y", but this option becomes useful if you wish to have a chart with multiple plots and multiple axes.  </p>
<pre lang="javascript">
chart.addPlot("default", {type: "Bars", hAxis: "cool x", 
	vAxis: "super y"});
</pre>
<p>Pie charts are very different by nature, and have a separate list of parameters.  I'll leave it up to you to explore the parameters for the pie chart, from <code>Pie.js</code>:</p>
<pre lang="javascript">
defaultParams: {
	labels: true,
	ticks: false,
	fixed: true,
	precision: 1,
	labelOffset: 20,
	labelStyle: "default",      // default/rows/auto
	htmlLabels: true            // use HTML to draw labels
},
optionalParams: {
	font: "",
	fontColor: "",
	radius: 0
},
</pre>
<p>One other type with unique options is the Grid.  This plot type will draw grid lines along your tick marks and supports the following four boolean options to determine if lines will be displayed at the horizontal or vertical, and major or minor axis tick marks.  We will learn more about axes and look at a sample including the Grid type in Part 2. Remember to require <code>dojox/charting/plot2d/Areas</code>.</p>
<pre lang="javascript">
chart.addPlot("default", {type: "Grid",
        hMajorLines: true, 
        hMinorLines: false,
        vMajorLines: true,
        vMinorLines: false});
</pre>
<p>Now, let's go back to our starting example and spruce it up a bit.  Let's add a shadow, some curve to our line, and markers on our data points.</p>
<pre lang="javascript">
chart.addPlot("default", {type: "Lines", markers: true, 
	tension:3, shadows: {dx: 2, dy: 2, dw: 2}});
</pre>
<p>And now our chart looks like this:</p>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/tension.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/tension.png" alt="Tension" title="Tension" width="325" height="197" class="alignnone size-full wp-image-5379" /></a></p>
<p>One last feature I'd like to touch on is adding multiple plots to the same chart.  Multiple plots can be of differing types and can all be configured separately.  Each plot you add with <code>addPlot()</code> will be layered behind the previous plot.  In addition, plots can have their own axes or share them with other plots on the chart.  Now, if we add an areas plot to our lines example, we can create the following effect.</p>
<pre lang="javascript">
require([
	"dojox/charting/Chart",
	"dojox/charting/plot2d/Lines",
	"dojox/charting/plot2d/Areas",
	"dojox/charting/axis2d/Default",
	"dojo/domReady!"
	],
	function (Chart) {
		var chart = new Chart("simplechart");
		chart.addPlot("default", {type: "Lines"});
		chart.addPlot("someOtherPlot", {type: "Areas"});
		chart.addAxis("x");
		chart.addAxis("y", {vertical: true});
		chart.addSeries("Series 1", [1, 2, 2, 3, 4, 5, 5, 7]);
		chart.addSeries("Series 2", [1, 1, 4, 2, 1, 6, 4, 3],
			{plot: "someOtherPlot", stroke: {color:"blue"}, fill: "blue"});
		chart.render();
	});
</pre>
<p><a href="http://www.sitepen.com/blog/wp-content/uploads/2012/10/plots2.png"><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/plots2.png" alt="Plots" title="Plots" width="308" height="197" class="alignnone size-full wp-image-5380" /></a></p>
<p>Continue reading <a href="http://www.sitepen.com/blog/2012/11/09/a-beginners-guide-to-dojo-charting-with-amd-part-2-of-2">Part 2 of Dojo Charting with AMD</a> where we will cover the options available in the addAxes() and addSeries() calls.</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/11/09/a-beginners-guide-to-dojo-charting-with-amd-part-1-of-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dojo Tutorial: Augmenting Objects</title>
		<link>http://www.sitepen.com/blog/2012/11/08/dojo-tutorial-augmenting-objects/</link>
		<comments>http://www.sitepen.com/blog/2012/11/08/dojo-tutorial-augmenting-objects/#comments</comments>
		<pubDate>Thu, 08 Nov 2012 16:59:02 +0000</pubDate>
		<dc:creator>Dylan Schiemann</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[dojo/_base/lang]]></category>
		<category><![CDATA[dojo18]]></category>
		<category><![CDATA[lang]]></category>
		<category><![CDATA[mixin]]></category>
		<category><![CDATA[objects]]></category>

		<guid isPermaLink="false">http://www.sitepen.com/blog/?p=5660</guid>
		<description><![CDATA[<p>As part of our great updates to the Dojo Tutorials for Dojo 1.8, we&#8217;ve been busy creating several new tutorials. Augmenting Objects In JavaScript applications, you&#8217;re working with objects all day long. This tutorial covers the features found in dojo/_base/lang for augmenting your objects efficiently. Without further ado, check out the Augmenting Objects tutorial for [...]</p><p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></description>
				<content:encoded><![CDATA[<p>As part of our great updates to the <a href="http://dojotoolkit.org/documentation/?ver=1.8">Dojo Tutorials for Dojo 1.8</a>, we&#8217;ve been busy creating several new tutorials.</p>
<h2>Augmenting Objects</h2>
<p><img src="http://www.sitepen.com/blog/wp-content/uploads/2012/10/preview.jpg" alt="Augmenting Objects" title="Augmenting Objects" width="200" height="200" class="size-full wp-image-5661" style="float:left; margin:0 1em 1em 0" /> In JavaScript applications, you&#8217;re working with objects all day long. This tutorial covers the features found in <code>dojo/_base/lang</code> for augmenting your objects efficiently.</p>
<p><strong>Without further ado, check out the <a href="http://dojotoolkit.org/documentation/tutorials/1.8/augmenting_objects/">Augmenting Objects tutorial for Dojo 1.8</a>, <a href="http://dojotoolkit.org/documentation/tutorials/1.7/augmenting_objects/">1.7</a>, or <a href="http://dojotoolkit.org/documentation/tutorials/1.6/augmenting_objects/">1.6</a>!</strong></p>
<h2>Want to see a specific Tutorial? Want to Learn More?</h2>
<p>Is there something you’d like to learn how to do with Dojo? Always wanted to know how something in Dojo works? Leave us a message in the blog comments and we’ll see about getting a tutorial created for you. Or <a href="http://www.sitepen.com/workshops/">sign-up for an upcoming SitePen Dojo Workshop</a> to get a fully immersive hands-on experience with Dojo.</p>
<p>SitePen offers beginner, intermediate, and advanced Dojo Toolkit workshops to make your development team as skilled and efficient as possible when creating dynamic, responsive web applications.  <a href="http://sitepen.com/services/workshops/index.php">Sign up today!</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.sitepen.com/blog/2012/11/08/dojo-tutorial-augmenting-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
