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

<channel>
	<title>Ryan Phelan &#187; Flex</title>
	<atom:link href="http://www.rphelan.com/category/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rphelan.com</link>
	<description>Exploring Flex, Design, and Visualization</description>
	<lastBuildDate>Thu, 12 Aug 2010 14:56:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>360&#124;Flex Indy Slides</title>
		<link>http://www.rphelan.com/2009/05/21/360flex-indy-slides/</link>
		<comments>http://www.rphelan.com/2009/05/21/360flex-indy-slides/#comments</comments>
		<pubDate>Fri, 22 May 2009 05:45:43 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Pixel Bender]]></category>
		<category><![CDATA[360Flex]]></category>

		<guid isPermaLink="false">http://www.rphelan.com/?p=280</guid>
		<description><![CDATA[The slides from my presentation on Pixel Bender at 360&#124;Flex Indianapolis are available here.  Thanks to those who attended, and thanks to Tom and John for putting on another great conference. I'm not a big fan of just zipping up all my source files and tossing out a download link because without some context, sample [...]]]></description>
			<content:encoded><![CDATA[<p>The slides from my presentation on Pixel Bender at 360|Flex Indianapolis are available <a href="http://www.rphelan.com/flex/RyanPhelan_PixelBender_360Flex.pdf">here</a>.  Thanks to those who attended, and thanks to Tom and John for putting on another great conference.</p>
<p><a href="http://www.rphelan.com/flex/RyanPhelan_PixelBender_360Flex.pdf"><img class="alignnone size-full wp-image-281" title="360|Flex Slides" src="http://www.rphelan.com/flex/uploads/2009/05/ryanphelan_pixelbender_360flex.png" alt="360|Flex Slides" width="400" height="225" /></a></p>
<p>I'm not a big fan of just zipping up all my source files and tossing out a download link because without some context, sample code isn't generally very useful.  Instead, I'll be doing several blog posts over the next few weeks with some detailed explanation to go with the code, so keep checking back.</p>
<p>If you have any questions about the material I presented, or just Pixel Bender or Flex in general, send them over.  I'd love to help.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rphelan.com/2009/05/21/360flex-indy-slides/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pixel Bender Blend Modes</title>
		<link>http://www.rphelan.com/2009/05/19/pixel-bender-blend-modes/</link>
		<comments>http://www.rphelan.com/2009/05/19/pixel-bender-blend-modes/#comments</comments>
		<pubDate>Tue, 19 May 2009 16:39:51 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Pixel Bender]]></category>
		<category><![CDATA[360Flex]]></category>
		<category><![CDATA[Color]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Effects]]></category>
		<category><![CDATA[Shaders]]></category>

		<guid isPermaLink="false">http://www.rphelan.com/?p=272</guid>
		<description><![CDATA[In preparation for my Pixel Bender talk at 360Flex I wanted to create an example which shows how to use Pixel Bender shaders as blend modes, so I went ahead and whipped together 20 blend shaders:  Darken, Multiply, Color Burn, Linear Burn, Lighten, Screen, Color Dodge, Linear Dodge (Additive), Overlay, Soft Light, Hard Light, Vivid [...]]]></description>
			<content:encoded><![CDATA[<p>In preparation for my Pixel Bender talk at 360Flex I wanted to create an example which shows how to use Pixel Bender shaders as blend modes, so I went ahead and whipped together 20 blend shaders:  Darken, Multiply, Color Burn, Linear Burn, Lighten, Screen, Color Dodge, Linear Dodge (Additive), Overlay, Soft Light, Hard Light, Vivid Light, Linear Light, Pin Light, Difference, Exclusion, Interpolation, Invert, Quadratic, and Subtract.</p>
<p>You'll notice there is some overlap with the set that are natively available in flash.display.BlendMode, but I thought it would be pretty educational to see how these shaders are written Pixel Bender.  I have yet to test to see if there is a significant performance difference.</p>
<p><a href="http://www.rphelan.com/flex/PBBlendModes/"><img class="alignnone size-full wp-image-273" title="Pixel Bender Blend Modes Preview" src="http://www.rphelan.com/flex/uploads/2009/05/pbblendmodes.png" alt="Pixel Bender Blend Modes Preview" width="485" height="263" /></a></p>
<p><a href="http://www.rphelan.com/flex/PBBlendModes/">Application</a> - <a href="http://www.rphelan.com/flex/PBBlendModes/srcview/index.html">Source</a></p>
<p>The formulas behind these blend modes were pretty easy to find.  I got them from a combination of <a href="http://www.pegtop.net/delphi/articles/blendmodes">http://www.pegtop.net/delphi/articles/blendmodes</a>, <a href="http://dunnbypaul.net/blends/">http://dunnbypaul.net/blends/</a>, wikipedia and the Flash docs.</p>
<p>One topic I wasn't able to find much documentation on was how to handle alpha channels for the various blend modes.  It gets complicated if both layers have transparency, and I'm not sure if there is a standardized way of computing the resulting alpha.  So for these examples the alpha is simply set to that of the input image.  This means that these blend modes work perfectly for opaque images, but vary from what you might see in photoshop when transparency is involved.  If anyone has any good resources on the topic or would like to contribute to this effort, let me know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rphelan.com/2009/05/19/pixel-bender-blend-modes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>BendPixels</title>
		<link>http://www.rphelan.com/2008/11/24/bendpixels/</link>
		<comments>http://www.rphelan.com/2008/11/24/bendpixels/#comments</comments>
		<pubDate>Mon, 24 Nov 2008 15:04:02 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Pixel Bender]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[Effects]]></category>

		<guid isPermaLink="false">http://www.rphelan.com/?p=235</guid>
		<description><![CDATA[BendPixels is a library by Mrinal Wadhwa which makes it possible to tween Pixel Bender filters using Flex's mx.effects library.  I finally got a chance to play with this and it really is pretty cool.  You can check out a demo here.  It is capable of tweening arbitrary shaders, and has wrappers for several popular [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/bendpixels/">BendPixels</a> is a library by Mrinal Wadhwa which makes it possible to tween Pixel Bender filters using Flex's mx.effects library.  I finally got a chance to play with this and it really is pretty cool.  You can check out a demo <a href="http://weblog.mrinalwadhwa.com/demos/BendPixelsExample/index.html">here</a>.  It is capable of tweening arbitrary shaders, and has wrappers for several popular effects from Adobe's <a href="http://www.adobe.com/cfusion/exchange/index.cfm?event=productHome&amp;exc=26&amp;loc=en_us">Pixel Bender Exchange</a>.  I am flattered that my very own Zoom Blur effect has been included.</p>
<p>My only criticism is that Flex effects in general tend to have lackluster performance.  I frequently use libraries like <a href="http://blog.greensock.com/tweenliteas3/">TweenLite</a> instead.  Can TweenLite play nicely with Pixel Bender effects?  Of course.  I'll do an example of that sometime this week.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rphelan.com/2008/11/24/bendpixels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spotlight Pixel Bender Filter</title>
		<link>http://www.rphelan.com/2008/10/28/spotlight-pixel-bender-filter/</link>
		<comments>http://www.rphelan.com/2008/10/28/spotlight-pixel-bender-filter/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 15:18:53 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Pixel Bender]]></category>
		<category><![CDATA[Colored Lighting]]></category>
		<category><![CDATA[Effects]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Lighting Effects]]></category>
		<category><![CDATA[Spotlight]]></category>

		<guid isPermaLink="false">http://www.rphelan.com/?p=219</guid>
		<description><![CDATA[This is an advanced filter which renders dynamic colored lighting on a display object in Flash.  Consider it a work in progress — It's not as full featured as Photoshop's "Lighting Effects" filter, but it is capable of creating a wide array of effects.  The kernel's main algorithm was ported from NVIDIA's Shader Library, but [...]]]></description>
			<content:encoded><![CDATA[<p>This is an advanced filter which renders dynamic colored lighting on a display object in Flash.  Consider it a work in progress — It's not as full featured as Photoshop's "Lighting Effects" filter, but it is capable of creating a wide array of effects.  The kernel's main algorithm was ported from <a href="http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html">NVIDIA's Shader Library</a>, but I had to make some pretty heavy modifications to make it more functional for the Flash world.  It has 8 parameters:  ambientColor, angle, azimuth, coneAngle, distance, intensity, position, and spotColor.</p>
<ul>
<li>ambientColor - color to apply to all pixels of the image</li>
<li>angle - angle at which the spotlight is projected (in degrees)</li>
<li>azimuth - angle between the image plane and the spotlight (in degrees)</li>
<li>coneAngle - angle of the spotlight's "opening" (in degrees)</li>
<li>distance - distance from the spotlight to the center point</li>
<li>intensity - intensity of the spotlight</li>
<li>position - x, y, z position of the spotlight</li>
<li>spotColor - color of the spotlight</li>
</ul>
<p>There are so many different ways that you could use this effect, I will probably devote a few more posts to showing additional examples.  In this demo, I created a couple of draggable handles that you can use for positioning the spotlight, and some preset configurations (try the dawn, day, and dusk buttons).  Next time, I'll incorporate some animation.</p>
<p><a href="http://www.rphelan.com/flex/SpotlightDemo/SpotlightDemo.html">Application</a> - <a href="http://www.rphelan.com/flex/SpotlightDemo/srcview/index.html">Source</a></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_SpotlightDemo_1914670266"
			class="flashmovie"
			width="420"
			height="600">
	<param name="movie" value="http://www.rphelan.com/flex/SpotlightDemo/SpotlightDemo.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.rphelan.com/flex/SpotlightDemo/SpotlightDemo.swf"
			name="fm_SpotlightDemo_1914670266"
			width="420"
			height="600">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://www.rphelan.com/2008/10/28/spotlight-pixel-bender-filter/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Magnify Pixel Bender Filter</title>
		<link>http://www.rphelan.com/2008/10/20/magnify-pixel-bender-filter/</link>
		<comments>http://www.rphelan.com/2008/10/20/magnify-pixel-bender-filter/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 14:27:01 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Pixel Bender]]></category>
		<category><![CDATA[Effects]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Magnify]]></category>

		<guid isPermaLink="false">http://www.rphelan.com/?p=200</guid>
		<description><![CDATA[The "Magnify" effect is an age old Flash trick that we used to accomplish using two images and some clever masking.  This pixel shader can achieve the same effect with less code, only 1 image, and has a few new tricks up its sleeve.  It magnifies a circular section of an image and optionally creates [...]]]></description>
			<content:encoded><![CDATA[<p>The "Magnify" effect is an age old Flash trick that we used to accomplish using two images and some clever masking.  This pixel shader can achieve the same effect with less code, only 1 image, and has a few new tricks up its sleeve.  It magnifies a circular section of an image and optionally creates a smooth transition between the magnified and unmagnified areas.  The four parameters are center, outerRadius, innerRadius, and magnification.</p>
<ul>
<li>center ([0-2048, 0-2048]) - the center coordinates of the magnified area</li>
<li>outerRadius (0-500) - the radius of the magnified part of the image</li>
<li>innerRadius (0-500) - the radius of the <em>fully </em>magnified part of the image</li>
<li>magnification (1-50) - the amount to magnify the image by (e.g. set to 2 for a 2x magnification)</li>
</ul>
<p><em>Note that the ranges specified above are just the recommendations from the .pbk file, you can set these values to whatever you want in your application.</em></p>
<p>Take some time and play around with the settings, it is possible to acheive a several different effects.  If innerRadius is 0, it creates a "bubble".  If it is higher than outerRadius, then you get a hard edged circle.  In this demo, I disabled values between 0 and 1 for magnification because they can create some strange side effects, but if you are careful you can use fractional magnifications to create a "pinch" type effect.</p>
<p><a href="http://www.rphelan.com/flex/MagnifyDemo/MagnifyDemo.html">Application</a> - <a href="http://www.rphelan.com/flex/MagnifyDemo/srcview/index.html">Source</a></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_MagnifyDemo_1349637739"
			class="flashmovie"
			width="450"
			height="475">
	<param name="movie" value="http://www.rphelan.com/flex/MagnifyDemo/MagnifyDemo.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.rphelan.com/flex/MagnifyDemo/MagnifyDemo.swf"
			name="fm_MagnifyDemo_1349637739"
			width="450"
			height="475">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://www.rphelan.com/2008/10/20/magnify-pixel-bender-filter/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Zoom Blur Pixel Bender Filter</title>
		<link>http://www.rphelan.com/2008/10/17/zoom-blur-pixel-bender-filter/</link>
		<comments>http://www.rphelan.com/2008/10/17/zoom-blur-pixel-bender-filter/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 15:58:16 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Pixel Bender]]></category>
		<category><![CDATA[Effects]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Zoom Blur]]></category>

		<guid isPermaLink="false">http://www.rphelan.com/?p=187</guid>
		<description><![CDATA[Zoom Blur does a 15 level zoom and blur about a specified focus point, and could be very useful for transition effects.  Its two properties are amount and center. amount (0 - 0.5) - the amount of blur to apply center ([0 - 2048, 0 - 2048]) - the focal point of the blur Application [...]]]></description>
			<content:encoded><![CDATA[<p>Zoom Blur does a 15 level zoom and blur about a specified focus point, and could be very useful for transition effects.  Its two properties are amount and center.</p>
<ul>
<li>amount (0 - 0.5) - the amount of blur to apply</li>
<li>center ([0 - 2048, 0 - 2048]) - the focal point of the blur</li>
</ul>
<p><a href="http://www.rphelan.com/flex/ZoomBlurDemo/ZoomBlurDemo.html">Application</a> - <a href="http://www.rphelan.com/flex/ZoomBlurDemo/srcview/index.html">Source</a></p>
<p><em>*Note:  This application requires <a href="http://www.adobe.com/go/getflash">Flash Player 10</a></em></p>
<p><em>Photo courtesy of my talented and beautiful girlfriend, <a href="http://www.bregehrken.com">Bre Gehrken</a>.<br />
</em></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ZoomBlurDemo_241554037"
			class="flashmovie"
			width="420"
			height="460">
	<param name="movie" value="http://www.rphelan.com/flex/ZoomBlurDemo/ZoomBlurDemo.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.rphelan.com/flex/ZoomBlurDemo/ZoomBlurDemo.swf"
			name="fm_ZoomBlurDemo_241554037"
			width="420"
			height="460">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://www.rphelan.com/2008/10/17/zoom-blur-pixel-bender-filter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sharpen Pixel Bender Filter</title>
		<link>http://www.rphelan.com/2008/10/17/sharpen-pixel-bender-filter/</link>
		<comments>http://www.rphelan.com/2008/10/17/sharpen-pixel-bender-filter/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 15:03:50 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Pixel Bender]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Sharpen]]></category>

		<guid isPermaLink="false">http://www.rphelan.com/?p=179</guid>
		<description><![CDATA[The Sharpen filter is similar to Photoshop's, it increases the apparant sharpness/definition of an image.  It has two parameters:  amount and radius. amount (0 - 20) - the amount to sharpen the image by radius (0 - 1) - pixel distance to sample from Application - Source *Note: This application requires Flash Player 10 Photo [...]]]></description>
			<content:encoded><![CDATA[<p>The Sharpen filter is similar to Photoshop's, it increases the apparant sharpness/definition of an image.  It has two parameters:  amount and radius.</p>
<ul>
<li>amount (0 - 20) - the amount to sharpen the image by</li>
<li>radius (0 - 1) - pixel distance to sample from</li>
</ul>
<p><a href="http://www.rphelan.com/flex/SharpenDemo/SharpenDemo.html">Application</a> - <a href="http://www.rphelan.com/flex/SharpenDemo/srcview/index.html">Source</a></p>
<p><em>*Note:  This application requires <a href="http://www.adobe.com/go/getflash">Flash Player 10</a></em></p>
<p><em>Photo courtesy of <a href="http://www.sxc.hu">stock.xchng</a></em></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_SharpenDemo_1758946595"
			class="flashmovie"
			width="420"
			height="450">
	<param name="movie" value="http://www.rphelan.com/flex/SharpenDemo/SharpenDemo.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.rphelan.com/flex/SharpenDemo/SharpenDemo.swf"
			name="fm_SharpenDemo_1758946595"
			width="420"
			height="450">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://www.rphelan.com/2008/10/17/sharpen-pixel-bender-filter/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Wave Reflection Pixel Bender Filter</title>
		<link>http://www.rphelan.com/2008/10/16/wave-reflection-pixel-bender-filter/</link>
		<comments>http://www.rphelan.com/2008/10/16/wave-reflection-pixel-bender-filter/#comments</comments>
		<pubDate>Thu, 16 Oct 2008 20:30:22 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Pixel Bender]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Reflection]]></category>
		<category><![CDATA[Water]]></category>

		<guid isPermaLink="false">http://www.rphelan.com/?p=157</guid>
		<description><![CDATA[Wave Reflection creates the effect of moving water over the surface of an image.  It differs from other wave and ripple effects in that it can be animated in a loop to create continuous ambient motion, and the ripples are not uniformly distributed across the image - they become more exaggerated towards the bottom.  The [...]]]></description>
			<content:encoded><![CDATA[<p>Wave Reflection creates the effect of moving water over the surface of an image.  It differs from other wave and ripple effects in that it can be animated in a loop to create continuous ambient motion, and the ripples are not uniformly distributed across the image - they become more exaggerated towards the bottom.  The three parameters are amplitude, frequency, and progress.</p>
<ul>
<li>amplitude (0-1) - the height of the waves</li>
<li>frequency (0-.54) - how close together the waves are.  Higher value = more waves.</li>
<li>progress (0-1) - percentage of the wave sequence.  Animate from 0 to 1 to get a smooth wave effect.</li>
</ul>
<p>This was my first go at a Pixel Bender filter, let me know what you think.  I've got a couple more in the works, so check back soon.</p>
<p><a href="http://www.rphelan.com/flex/WaveReflectionDemo/WaveReflectionDemo.html">Application</a> - <a href="http://www.rphelan.com/flex/WaveReflectionDemo/srcview/index.html">Source</a></p>
<p><em>*Note:  This application requires <a href="http://www.adobe.com/go/getflash">Flash Player 10</a></em></p>
<p><em>Photo courtesy of <a href="http://www.sxc.hu">stock.xchng</a></em></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_WaveReflectionDemo_401508548"
			class="flashmovie"
			width="420"
			height="550">
	<param name="movie" value="http://www.rphelan.com/flex/WaveReflectionDemo/WaveReflectionDemo.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://www.rphelan.com/flex/WaveReflectionDemo/WaveReflectionDemo.swf"
			name="fm_WaveReflectionDemo_401508548"
			width="420"
			height="550">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://www.rphelan.com/2008/10/16/wave-reflection-pixel-bender-filter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Taking Control of Flex Charting Styles</title>
		<link>http://www.rphelan.com/2008/05/23/taking-control-of-flex-charting-styles/</link>
		<comments>http://www.rphelan.com/2008/05/23/taking-control-of-flex-charting-styles/#comments</comments>
		<pubDate>Fri, 23 May 2008 20:47:24 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Visualization]]></category>
		<category><![CDATA[Color]]></category>
		<category><![CDATA[Data Visualization]]></category>
		<category><![CDATA[Flex Charting]]></category>

		<guid isPermaLink="false">http://www.rphelan.com/?p=36</guid>
		<description><![CDATA[This is a guide to help you modify the Flex charting components' default styles to create charts that are more attractive and easier to comprehend. I have a fairly long history with building charting components in Flash and Flex. My first job involved developing a suite of "drag and drop" charts and other modeling tools [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is a guide to help you modify the Flex charting components' default styles to create charts that are more attractive and easier to comprehend.</em></p>
<p>I have a fairly long history with building charting components in Flash and Flex.  My first job involved developing a suite of "drag and drop" charts and other modeling tools in Flash for a financial modeling application.  Now I am working at Gallup, Inc. (the guys who do "the Gallup Poll"...) and have authored a Flex application which renders charts for <a href="http://www.gallup.com">gallup.com</a> articles.  Along the way I've studied works by <a href="http://www.edwardtufte.com">Edward Tufte</a> (he's been called "the DaVinci of data visualization") as well as <a href="http://www.perceptualedge.com/">Stephen Few</a> (who offers some great practical application to Tufte's theory) and others.  Given all the research that has been done in human perception and data visualization, I feel that the default styles for the Flex charting components need a bit of tweaking to really optimize their usability.  (Also, from what I've seen of the ILOG Elixir library, those charts need <em>A LOT</em> of tweaking... but let's try to stay on topic ;).  This article will kick off a series where I will share some of my tricks for making charting components that are both aesthetically pleasing and easy to comprehend.</p>
<h4>Getting Started</h4>
<p>I'm going to focus on the 3 basic chart types:  LineChart, ColumnChart, and BarChart, and you can apply many of these tricks to other more complex types.  I created a simple application which sticks one of each chart type in a TabNavigator, gives them some data providers, and sets up the series.  Its pretty basic, no special styles are applied. <em>I realize that this would be a very poor structure for a real application - I'm organizing it in the way that best illustrates the techniques below.</em></p>
<p><img class="aligncenter size-full wp-image-41" title="Before" src="http://www.rphelan.com/flex/uploads/2008/05/before.png" alt="Before" width="410" height="270" /></p>
<p>From this point on you may find it useful to follow along with the source in the final application.</p>
<p><a href="http://www.rphelan.com/flex/ChartStyles/">Application</a> - <a href="http://www.rphelan.com/flex/ChartStyles/srcview/">Source</a></p>
<h4>Develop a Color Scheme</h4>
<p>I could write an entire post on the use of color (and I might in the future), but I'll cover this briefly.  Usually, you want all of your series to have equal visual weight, so the two obvious options are to vary the hue, or to vary the brightness and saturation.  One thing to keep in mind when varying hue though, is that about 1 in 76 people (thats 3.5 million in the US alone) have some sort of color deficit, the most common being red-green color blindness.  Selecting red and green colors that don't vary significantly in brightness can make your chart very difficult to interpret for a fairly significant part of the population.  It also might make your colors indistinguishable when printed in grayscale.   Let's play it safe by using the second option.  A great resource that I have used on many occasions is <a href="http://www.personal.psu.edu/cab38/ColorBrewer/ColorBrewer_intro.html">Color Brewer</a>, which was developed by Cynthia Brewer to create good color schemes for maps.  The same schemes work great for graphs too!  I set it to "sequential" and selected a blue scheme which should work very nicely.</p>
<p>To apply your selected colors, set the "fill" property on each series.  You can bind to a SolidColor object created in actionscript, or inline a <code>&lt;fill&gt;</code> tag in mxml.</p>
<h4>Changing The Default Styles</h4>
<p>First thing's first:  the drop shadows have to go.  I'm all for using filters and effects in Flex applications, but they really tend to get in the way of the data when used in charts.  This is an easy fix.  Just set <code>seriesFilters="[]"</code> for each chart.</p>
<p>Similarly, since outlining bars will also add extra clutter, I will set <code>stroke="{null}"</code> for each series (BarSeries and ColumnSeries).</p>
<p>Now, because we want to override a lot of default settings on the Axis, AxisRenderers and GridLines, we'll have to explicitly lay them out in mxml for each chart type.  For the BarChart it will look something like this:</p>
<p><img class="alignleft size-full wp-image-37" style="display:block;" title="Explicit BarChart Elements" src="http://www.rphelan.com/flex/uploads/2008/05/charting1.png" alt="Explicit BarChart Elements" width="271" height="371" /></p>
<h4>AxisRenderers</h4>
<p>Rather than the fat blue axis that is available by default, I prefer to use a thinner light gray stroke instead.  The only purpose of the axis line is to provide a little visual separation between the categories (or dates) and the data - so it doesn't need a lot of visual weight.  The axis that runs along the LinearAxis (eg the horizontal one on a BarChart, or the vertical one on a ColumnChart) won't be necessary at all.  It will be implied by the grid lines which will all come to an end right at the axis.  To turn it off, set <code>showLine="false"</code>.</p>
<p><img class="aligncenter size-full wp-image-39" title="Implied Axis" src="http://www.rphelan.com/flex/uploads/2008/05/charting2.png" alt="Implied Axis" width="418" height="111" /></p>
<p><em>Update:  To improve the readability of the graph i have use the labelGap property to increase the gap from it's default of 3 to 10-12 on each axis.</em></p>
<h4>GridLines</h4>
<p>Even the grid lines are often non-essential to the readability of the graph.  When the data permits it, I prefer to use <a href="http://demo.quietlyscheming.com/ChartSampler/app.html">Ely Greenfield's bar labels</a> and leave the gridlines off all together.   This results in a super clean and modern look.  For the sake of example though, I included them here.</p>
<p>You always want the grid lines to run perpendicular to the LinearAxis.  (The only time I can think of that you would want them running both ways is in a chart with 2 linear axes, like a scatter plot).  You control this by setting <code>direction="vertical"</code> or <code>direction="horizontal"</code> on the GridLines element.  Likewise, we only want to display the origin (i.e. 0) for the same direction.  So on a ColumnChart, you would set <code>direction="horizontal"</code>, <code>verticalShowOrigin="false"</code> and <code>horizontalShowOrigin="true"</code>.  On a BarChart, you would set <code>direction="vertical"</code>, <code>verticalShowOrigin="true"</code> and <code>horizontalShowOrigin="false"</code>.</p>
<p>I chose to make the stroke for the origin the same as the stroke for the Axis:  light gray with 3 pixel weight.  The stroke for the grid lines themselves should be very faint - no more than 1 pixel wide and only slightly lighter or darker than the background color.  We don't want the grid lines to compete for the viewer's attention along with the actual data.</p>
<p>The final trick I employed here was offsetting the gridlines -.5 pixels.  This solves a glitch where the top line doesn't always display.  Try removing the line <code>x="-.5"</code> in the SampleBarChart class and you will see what I mean.  Obviously this is a hack, but it has worked pretty well for me thus far.</p>
<h4>LineCharts</h4>
<p>There aren't many differences here except we are setting the "lineStroke" style instead of "fill" on the series.  My rule of thumb is that the thickness of the line should approximately equal width/number of points or 3, whichever is less.  This is a very general heuristic, but will help ensure that in very dense data sets, the thickness of the line doesn't obscure the data points.  Because this isn't easy to generalize for all different types of dataProviders and because my data set isn't dynamic, I just set the weight to 3.</p>
<p>I also added a labelFunction to the DateTimeAxis so that the dates would show up in a more readable format.  "Feb 2008" is much more readable than "2/08".</p>
<h4>The Final Product</h4>
<p><img class="aligncenter size-full wp-image-42" title="After" src="http://www.rphelan.com/flex/uploads/2008/05/after.png" alt="After" width="410" height="274" /></p>
<p>That's it!  You could further improve on this example by adding a legend, selecting a better font, and maybe embedding the text - but I'll leave that for you to experiment with.   Of course these settings won't work for every situation, but I think it makes for a good starting point for whatever types of data you might come across.  As you probably have noticed, the emphasis is all on simplicity.  By removing the extra "fluff", you create a chart where the data is the main focus and enable the user to have the best possible experience.</p>
<p>If you have additional suggestions, or questions regarding chart styles feel free to comment.</p>
<p><a href="http://www.rphelan.com/flex/ChartStyles/">Application</a> - <a href="http://www.rphelan.com/flex/ChartStyles/srcview/">Source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rphelan.com/2008/05/23/taking-control-of-flex-charting-styles/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Source Code Formatter for Flex Builder?</title>
		<link>http://www.rphelan.com/2008/04/16/source-code-formatter-for-flex-builder/</link>
		<comments>http://www.rphelan.com/2008/04/16/source-code-formatter-for-flex-builder/#comments</comments>
		<pubDate>Wed, 16 Apr 2008 14:30:47 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex Builder]]></category>
		<category><![CDATA[Flex 4]]></category>

		<guid isPermaLink="false">http://www.rphelan.com/?p=27</guid>
		<description><![CDATA[http://bugs.adobe.com/jira/browse/FB-8297 I added myself as a watcher to this feature request ages ago, and yesterday it got mysteriously re-opened and marked as "Internal Review". Here's hoping they include it in Flex 4. Go there and vote!]]></description>
			<content:encoded><![CDATA[<p><a href="http://bugs.adobe.com/jira/browse/FB-8297">http://bugs.adobe.com/jira/browse/FB-8297</a></p>
<p>I added myself as a watcher to this feature request ages ago, and yesterday it got mysteriously re-opened and marked as "Internal Review".  Here's hoping they include it in Flex 4.  Go there and vote!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rphelan.com/2008/04/16/source-code-formatter-for-flex-builder/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
