<?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>Made of Everything You&#039;re Not &#187; charts</title>
	<atom:link href="http://blog.ericlamb.net/tag/charts/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ericlamb.net</link>
	<description>Thoughts on programming, people and life</description>
	<lastBuildDate>Thu, 29 Jul 2010 07:00:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>pChart &#8211; a PHP class to build charts</title>
		<link>http://blog.ericlamb.net/2009/09/pchart-a-php-class-to-build-charts/</link>
		<comments>http://blog.ericlamb.net/2009/09/pchart-a-php-class-to-build-charts/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 13:00:43 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[charts]]></category>
		<category><![CDATA[graphs]]></category>
		<category><![CDATA[pchart]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=1459</guid>
		<description><![CDATA[In my never ending quest to find a replacement for JpGraph  I&#8217;ve covered charts built using JavaScript with the Google Visualization API and charts done with SWFs using Open Flash Charts (OFS). If you&#8217;re building web apps it&#8217;s easy to just stop there and consider yourself covered. I certainly thought so; until my conscience spoke [...]]]></description>
			<content:encoded><![CDATA[<p>In my never ending quest to find a replacement for JpGraph  I&#8217;ve covered charts built using JavaScript with the <a title="Google Visualization API Primer" href="http://blog.ericlamb.net/2009/03/google-visualization-api-primer/" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2F2009%2F03%2Fgoogle-visualization-api-primer%2F','Google+Visualization+API+Primer')" target="_self">Google Visualization API</a> and charts done with SWFs using <a title="Prettify Data with Open Flash Chart" href="http://blog.ericlamb.net/2009/06/pretty-data-with-open-flash-chart/" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2F2009%2F06%2Fpretty-data-with-open-flash-chart%2F','Prettify+Data+with+Open+Flash+Chart')" target="_self">Open Flash Charts</a> (OFS). If you&#8217;re building web apps it&#8217;s easy to just stop there and consider yourself covered. I certainly thought so; until my conscience spoke up that is.</p>
<div id="attachment_2473" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2009/09/pchart_example.png" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F09%2Fpchart_example.png','pChart')"><img class="size-medium wp-image-2473" title="pChart " src="http://blog.ericlamb.net/wp-content/uploads/2009/09/pchart_example-300x157.png" alt="pChart " width="300" height="157" /></a><p class="wp-caption-text">pChart </p></div>
<p>The thought them comes creaping into my head, &#8220;Um&#8230; What about the JavaScript? How do you think those pretty charts and graphs will degrade?&#8221;.</p>
<p>Shit.</p>
<p>Not to take anything away from either of those programs; they&#8217;re very fun to work with and, relatively, easy to use. It&#8217;s just that they&#8217;re both rendered using JavaScript which is well and good provided your user has JavaScript enabled (and Flash too for OFS). It&#8217;d be a nice addition to provide an alternative when using either one of the previous programs.</p>
<p>This is where <a title="pChart" href="http://pchart.sourceforge.net/" onclick="return TrackClick('http%3A%2F%2Fpchart.sourceforge.net%2F','pChart')" target="_blank">pChart</a> comes in:</p>
<blockquote><p>pChart is a PHP class oriented framework designed to create aliased charts. Most of todays chart libraries have a cost, our project is intended to be free. Data can be retrieved from SQL queries, CSV files, or manually provided. This project is still under development and new features or fix are made every week.</p>
<p>Focus has been put on rendering quality introducing an aliasing algorithm to draw eye candy graphics. Rendering speed has been dramatically enhanced since the first version, we&#8217;ll still continue optimising the code!</p></blockquote>
<p>Implementation is pretty easy too:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Standard inclusions</span>
<span style="color: #22f;">include</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;pChart/pData.class&quot;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #22f;">include</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;pChart/pChart.class&quot;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Dataset definition</span>
<span style="color: #000088;">$DataSet</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> pData<span style="color: #339933;">;</span>
<span style="color: #000088;">$DataSet</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>AddPoint<span style="color: #000;">&#40;</span><span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">7</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">7</span><span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$DataSet</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>AddSerie<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$DataSet</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>SetSerieName<span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;Sample data&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;Serie1&quot;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Initialise the graph</span>
<span style="color: #000088;">$Test</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> pChart<span style="color: #000;">&#40;</span><span style="color: #cc66cc;">700</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">230</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$Test</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setFontProperties<span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;Fonts/tahoma.ttf&quot;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$Test</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setGraphArea<span style="color: #000;">&#40;</span><span style="color: #cc66cc;">40</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">30</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">680</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">200</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$Test</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>drawGraphArea<span style="color: #000;">&#40;</span><span style="color: #cc66cc;">252</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">252</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">252</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$Test</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>drawScale<span style="color: #000;">&#40;</span><span style="color: #000088;">$DataSet</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>GetData<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$DataSet</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>GetDataDescription<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">,</span>SCALE_NORMAL<span style="color: #339933;">,</span><span style="color: #cc66cc;">150</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">150</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">150</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$Test</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>drawGrid<span style="color: #000;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span><span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">230</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">230</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">230</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">255</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Draw the line graph</span>
<span style="color: #000088;">$Test</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>drawLineGraph<span style="color: #000;">&#40;</span><span style="color: #000088;">$DataSet</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>GetData<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$DataSet</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>GetDataDescription<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$Test</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>drawPlotGraph<span style="color: #000;">&#40;</span><span style="color: #000088;">$DataSet</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>GetData<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$DataSet</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>GetDataDescription<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">255</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Finish the graph</span>
<span style="color: #000088;">$Test</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setFontProperties<span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;Fonts/tahoma.ttf&quot;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">8</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$Test</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>drawLegend<span style="color: #000;">&#40;</span><span style="color: #cc66cc;">45</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">35</span><span style="color: #339933;">,</span><span style="color: #000088;">$DataSet</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>GetDataDescription<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">255</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">255</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$Test</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>setFontProperties<span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;Fonts/tahoma.ttf&quot;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">10</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$Test</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>drawTitle<span style="color: #000;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">22</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;My pretty graph&quot;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">50</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">585</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$Test</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>Render<span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;Naked.png&quot;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
?<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span></pre></div></div>

<p>The above code produces something similar to:</p>
<div id="attachment_2477" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2009/09/pchart_example_line.png" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F09%2Fpchart_example_line.png','pChart+Linechart+Example')"><img class="size-medium wp-image-2477" title="pChart Linechart Example" src="http://blog.ericlamb.net/wp-content/uploads/2009/09/pchart_example_line-300x98.png" alt="pChart Linechart Example" width="300" height="98" /></a><p class="wp-caption-text">pChart Linechart Example</p></div>
<p>One really cool addition the developers added was a little cmd script, buildAll.cmd, to automate the build of all the Example scripts on Windows machines. Just double click that and you&#8217;ll have all the graph images generated automatically.</p>
<p>It is recommended by the developers that caching is implemented but I haven&#8217;t really found the need for it yet.</p>
<p>A good idea, and one I&#8217;m going to be implementing, is to use charts and graphs created with OFC and create static image graphs for the noscript tags using pChart. Definitely a lot of work but it&#8217;ll add a bit of shiny to my programs. Yours too I think.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2009/09/pchart-a-php-class-to-build-charts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Prettify Data with Open Flash Chart</title>
		<link>http://blog.ericlamb.net/2009/06/pretty-data-with-open-flash-chart/</link>
		<comments>http://blog.ericlamb.net/2009/06/pretty-data-with-open-flash-chart/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 13:00:52 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[charts]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[graphs]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=1457</guid>
		<description><![CDATA[Everyone likes the pretty. The pretty makes people feel nice and adds a sense of peace and comfort. The pretty is good and brings joy to small children. We all want our data to be pretty. Tables of numbers just aren&#8217;t fun for anyone. Except programmers; we don&#8217;t give a shit. Oddly though, PHP hasn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Everyone likes the pretty. The pretty makes people feel nice and adds a sense of peace and comfort. The pretty is good and brings joy to small children.</p>
<div id="attachment_1882" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2009/06/open_flash_charts.gif" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F06%2Fopen_flash_charts.gif','Open+Flash+Charts')"><img class="size-medium wp-image-1882" title="Open Flash Charts" src="http://blog.ericlamb.net/wp-content/uploads/2009/06/open_flash_charts-300x118.gif" alt="Open Flash Charts" width="300" height="118" /></a><p class="wp-caption-text">Open Flash Charts</p></div>
<p>We all want our data to be pretty. Tables of numbers just aren&#8217;t fun for anyone. Except programmers; we don&#8217;t give a shit.</p>
<p>Oddly though, PHP hasn&#8217;t had many options for pretty charts and graphs. Sure, we have <a title="JpGraph" href="http://www.aditus.nu/jpgraph/" onclick="return TrackClick('http%3A%2F%2Fwww.aditus.nu%2Fjpgraph%2F','JpGraph')" target="_blank">JpGraph</a> but it&#8217;s a little cumbersome and&#8230; well ugly&#8217;s a good word for it. Recently I heard about <a title="pChart" href="http://pchart.sourceforge.net/" onclick="return TrackClick('http%3A%2F%2Fpchart.sourceforge.net%2F','pChart')" target="_self">pChart</a>, which I&#8217;ll be writing about another time, but aside from the cosmetic upgrade it doesn&#8217;t seem too different than JpGraph. </p>
<p>I&#8217;ve already gone into some detail about the <a title="Google Visualization API Primer" href="http://blog.ericlamb.net/2009/03/google-visualization-api-primer/" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2F2009%2F03%2Fgoogle-visualization-api-primer%2F','Google+Visualization+API+Primer')" target="_self">Google Visualization API</a>, which is a pretty good JavaScript implementation for creating charts and graphs, but that too is a little challenging to implement.</p>
<p>I&#8217;ve recently become enthralled with <a title="Open Flash Charts" href="http://teethgrinder.co.uk/open-flash-chart/" onclick="return TrackClick('http%3A%2F%2Fteethgrinder.co.uk%2Fopen-flash-chart%2F','Open+Flash+Charts+v1')" onclick="return TrackClick('http%3A%2F%2Fteethgrinder.co.uk%2Fopen-flash-chart%2F','Open+Flash+Charts')" target="_blank">Open Flash Charts</a> (OFC) though. OFC is an open source flash charting system that uses external data-files to keep the program language agnostic. You can use pretty much any web programming language, so long as it can output strings, and you&#8217;re in business. In fact, there are libraries for a slew of languages including .NET, perl, python and ruby packaged right along with the download. </p>
<p>OFC was started because, I shit you not, the initial developer was burned by a vendor when looking for support on a PAID product. So he did what any programmer would do; wrote an open source version to help put that crappy company in hot water. Kudos <img src='http://blog.ericlamb.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>It&#8217;s a pretty slick setup though. OFC works by embedding a swf in a webpage and then setting a flashvar to point to a datafile on the server. Simple. Well&#8230; sort of&#8230;</p>
<p>There are 2 different versions to use; each given the very original titles <a title="Open Flash Charts v1" href="http://teethgrinder.co.uk/open-flash-chart/" onclick="return TrackClick('http%3A%2F%2Fteethgrinder.co.uk%2Fopen-flash-chart%2F','Open+Flash+Charts+v1')" onclick="return TrackClick('http%3A%2F%2Fteethgrinder.co.uk%2Fopen-flash-chart%2F','Open+Flash+Charts')" target="_blank">v1</a> and <a title="Open Flash Charts v2" href="http://teethgrinder.co.uk/open-flash-chart-2/" onclick="return TrackClick('http%3A%2F%2Fteethgrinder.co.uk%2Fopen-flash-chart-2%2F','Open+Flash+Charts+v2')" target="_blank">v2</a> respectively. Near as I can tell the latest version uses JSON as the data format while version 1 uses something a little more&#8230; generic. The problem is that version 2 has only a couple examples and version 1 has a ton so while I like to use the latest and greatest I have to stick with version 1 for now. That&#8217;s what this article is going to focus on.</p>
<p>First, to get started, be sure to download the files from SourceForge. The download for version 1 was a little hard to find so, in the interest of helping others, I&#8217;m providing a direct link to download <a title="Download Open Flash Charts 1.9.7" href="http://superb-west.dl.sourceforge.net/sourceforge/openflashchart/open-flash-chart-1.9.7.zip" onclick="return TrackClick('http%3A%2F%2Fsuperb-west.dl.sourceforge.net%2Fsourceforge%2Fopenflashchart%2Fopen-flash-chart-1.9.7.zip','Download+Open+Flash+Charts+1.9.7')">Open Flash Charts version 1.9.7</a>. The download includes the swf, which you&#8217;ll obviously need to embed in your page, and the wrapper code which is provided in quite a few different lanuages (if you don&#8217;t do php).</p>
<p>Using the wrapper code makes creating the <em>really</em> complicated strings for the swf to absorb. Sure, you could do it by hand, but why the fuck would you?</p>
<p>The official site acutally has some really good examples of how to <a href="http://teethgrinder.co.uk/open-flash-chart/tutorial.php" onclick="return TrackClick('http%3A%2F%2Fteethgrinder.co.uk%2Fopen-flash-chart%2Ftutorial.php','How+it+works')" title="How it works" target="_blank">work with the code</a>, so I won&#8217;t go into that too much here. Suffice it to say it&#8217;s pretty easy to create charts and graphs. The hardest part is getting used to the process of instantiating the code in the template (HTML) and then creating a stand alone script that gets hit by the swf for the data.</p>
<p>The HTML portion of the code is the simplest; you include the library (if it hasn&#8217;t been done already) and call a function like so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #22f;">include_once</span> <span style="color: #0000ff;">'ofc-library/open_flash_chart_object.php'</span><span style="color: #339933;">;</span>
open_flash_chart_object<span style="color: #000;">&#40;</span> <span style="color: #000088;">$width</span><span style="color: #339933;">,</span> <span style="color: #000088;">$height</span><span style="color: #339933;">,</span> <span style="color: #000088;">$url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$use_swfobject</span><span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #000088;">$base</span><span style="color: #339933;">=</span><span style="color: #0000ff;">''</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>The only two that should be confusing is $base and $url. </p>
<p>$base is useful if you don&#8217;t store the swf inside the site&#8217;s root directory; just set $base to the path, from your sites document root and you&#8217;re good.<br />
For example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//BAD</span>
<span style="color: #666666; font-style: italic;">//$base = $_SERVER['DOCUMENT_ROOT'].'/path/to/open-flash-chart.swf';</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//GOOD</span>
<span style="color: #000088;">$base</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/path/to/open-flash-chart.swf'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>$url is the full URL to the sister script to provide the options and data to the swf. It&#8217;s important to keep in mind that all the options for the swf are provided by this script. Seriously, all the options. What type of graph to generate, the data for the graph, the style for the graph, everything is generated on the server. The swf just interprets that data and draws accordingly.</p>
<p>The code for the sister script is a little more complicated but pretty straight forward once you understand it. NOTE, this was taken line for line from the official site:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// generate some random data:</span>
<span style="color: #990000;">srand</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#40;</span>double<span style="color: #000;">&#41;</span><span style="color: #990000;">microtime</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">1000000</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$max</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">50</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #22f;">for</span><span style="color: #000;">&#40;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">12</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span> <span style="color: #000;">&#41;</span>
<span style="color: #000;">&#123;</span>
  <span style="color: #000088;">$data</span><span style="color: #000;">&#91;</span><span style="color: #000;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #000;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$max</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// use the chart class to build the chart:</span>
<span style="color: #22f;">include_once</span><span style="color: #000;">&#40;</span> <span style="color: #0000ff;">'ofc-library/open-flash-chart.php'</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$g</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> graph<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Spoon sales, March 2007</span>
<span style="color: #000088;">$g</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">title</span><span style="color: #000;">&#40;</span> <span style="color: #0000ff;">'Spoon sales '</span><span style="color: #339933;">.</span> <span style="color: #990000;">date</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">&quot;Y&quot;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'{font-size: 26px;}'</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$g</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_data</span><span style="color: #000;">&#40;</span> <span style="color: #000088;">$data</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// label each point with its value</span>
<span style="color: #000088;">$g</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_x_labels</span><span style="color: #000;">&#40;</span> <span style="color: #990000;">array</span><span style="color: #000;">&#40;</span><span style="color: #0000ff;">'Jan'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Feb'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Mar'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Apr'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'May'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Jun'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Jul'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Aug'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Sep'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Oct'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Nov'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Dec'</span> <span style="color: #000;">&#41;</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// set the Y max</span>
<span style="color: #000088;">$g</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set_y_max</span><span style="color: #000;">&#40;</span> <span style="color: #cc66cc;">60</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// label every 20 (0,20,40,60)</span>
<span style="color: #000088;">$g</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">y_label_steps</span><span style="color: #000;">&#40;</span> <span style="color: #cc66cc;">6</span> <span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// display the data</span>
<span style="color: #22f;">echo</span> <span style="color: #000088;">$g</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">render</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>The above outputs a line chart like the below graph:</p>
<div id="attachment_1902" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2009/06/example_graph.gif" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F06%2Fexample_graph.gif','Example+Graph')"><img src="http://blog.ericlamb.net/wp-content/uploads/2009/06/example_graph-300x149.gif" alt="Example Graph" title="Example Graph" width="300" height="149" class="size-medium wp-image-1902" /></a><p class="wp-caption-text">Example Graph</p></div>
<p>OFC is definitely worth a look for the pretty.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2009/06/pretty-data-with-open-flash-chart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Visualization API Primer</title>
		<link>http://blog.ericlamb.net/2009/03/google-visualization-api-primer/</link>
		<comments>http://blog.ericlamb.net/2009/03/google-visualization-api-primer/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 13:25:10 +0000</pubDate>
		<dc:creator>Eric Lamb</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[charts]]></category>
		<category><![CDATA[google visualization api]]></category>
		<category><![CDATA[graphs]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://blog.ericlamb.net/?p=1252</guid>
		<description><![CDATA[The Google Visualization API is a JavaScript API for creating those fancy graphs and charts Google displays in all their cool toys like Google Analytics. There&#8217;s just an obnoxious amount of chart types available in the Visualization API Gallery that include code samples along with every example. There&#8217;s also the incredible Google Ajax API Playground [...]]]></description>
			<content:encoded><![CDATA[<p>The <a title="Google Visualization API" href="http://code.google.com/apis/visualization/" onclick="return TrackClick('http%3A%2F%2Fcode.google.com%2Fapis%2Fvisualization%2F','Google+Visualization+API')" target="_blank">Google Visualization API</a> is a JavaScript API for creating those fancy graphs and charts Google displays in all their cool toys like Google Analytics. There&#8217;s just an obnoxious amount of chart types available in the <a title="Google Visualization API Gallery" href="http://code.google.com/apis/visualization/documentation/gallery.html" onclick="return TrackClick('http%3A%2F%2Fcode.google.com%2Fapis%2Fvisualization%2Fdocumentation%2Fgallery.html','Google+Visualization+API+Gallery')" target="_blank">Visualization API Gallery</a> that include code samples along with every example. There&#8217;s also the incredible <a title="The Google Ajax API Playground" href="http://code.google.com/apis/ajax/playground/?type=visualization" onclick="return TrackClick('http%3A%2F%2Fcode.google.com%2Fapis%2Fajax%2Fplayground%2F%3Ftype%3Dvisualization','The+Google+Ajax+API+Playground')" target="_blank">Google Ajax API Playground</a> which lets you play with the API and see real-time output.</p>
<div id="attachment_1253" class="wp-caption aligncenter" style="width: 280px"><a href="http://blog.ericlamb.net/wp-content/uploads/2009/03/google_visualization.gif" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F03%2Fgoogle_visualization.gif','Google+Visualization')"><img class="size-full wp-image-1253" title="Google Visualization" src="http://blog.ericlamb.net/wp-content/uploads/2009/03/google_visualization.gif" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F03%2Fgoogle_visualization.gif','Google+Visualization')" alt="Google Visualization" width="270" height="200" /></a><p class="wp-caption-text">Google Visualization</p></div>
<p>According the official website:</p>
<blockquote><p>
The Google Visualization API lets you access multiple sources of structured data that you can display, choosing from a large selection of visualizations. Google Visualization API enables you to expose your own data, stored on any data-store that is connected to the web, as a Visualization compliant datasource. Thus you can create reports and dashboards as well as analyze and display your data through the wealth of available visualization applications. The Google Visualization API also provides a platform that can be used to create, share and reuse visualizations written by the developer community at large.
</p></blockquote>
<p>I have no real interest in publishing public widgets and I&#8217;ve only used the API by generating the data declarations; so far anyway. That&#8217;s actually what&#8217;s so compelling about the API; since it&#8217;s JavaScript based the API can be used with any server side language.</p>
<p>I&#8217;m mostly interested in using the charts and graphs for displaying data from a database on a website so that&#8217;s all this article is going to focus on. </p>
<p>One more thing to keep in mind; the API is just JavaScript. There&#8217;s nothing too fancy or random being done so even though the below may look complicated don&#8217;t forget; IT&#8217;S JUST JAVASCRIPT.</p>
<h3>Examples</h3>
<h4>Line Chart</h4>
<div id="attachment_1257" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2009/03/line_chart.jpg" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F03%2Fline_chart.jpg','Line+Chart')"><img src="http://blog.ericlamb.net/wp-content/uploads/2009/03/line_chart-300x138.jpg" alt="Line Chart" title="Line Chart" width="300" height="138" class="size-medium wp-image-1257" /></a><p class="wp-caption-text">Line Chart</p></div>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	google.<span style="color: #660066;">load</span><span style="color: #000;">&#40;</span><span style="color: #3366CC;">&quot;visualization&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #339933;">,</span> <span style="color: #000;">&#123;</span>packages<span style="color: #339933;">:</span><span style="color: #000;">&#91;</span><span style="color: #3366CC;">&quot;linechart&quot;</span><span style="color: #000;">&#93;</span><span style="color: #000;">&#125;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	google.<span style="color: #660066;">setOnLoadCallback</span><span style="color: #000;">&#40;</span>drawChart<span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">function</span> drawChart<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">visualization</span>.<span style="color: #660066;">DataTable</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">addColumn</span><span style="color: #000;">&#40;</span><span style="color: #3366CC;">'string'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Date'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">addColumn</span><span style="color: #000;">&#40;</span><span style="color: #3366CC;">'number'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Clicks'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">addRows</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">15</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 14, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 15, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 16, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 17, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 18, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 19, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">6</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 20, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">7</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 21, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">8</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 22, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">9</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 23, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 24, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">11</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 25, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">12</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 26, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">13</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 27, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">14</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'March 28, 2009'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>	  
                data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">13</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">27</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">15</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">12</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">15</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">6</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">8</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">7</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">9</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">8</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">15</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">9</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">12</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">8</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">11</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">21</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">12</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">13</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">7</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		data.<span style="color: #660066;">setCell</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">14</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">3</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> chart <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">visualization</span>.<span style="color: #660066;">LineChart</span><span style="color: #000;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #000;">&#40;</span><span style="color: #3366CC;">'click_chart_div'</span><span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
		chart.<span style="color: #660066;">draw</span><span style="color: #000;">&#40;</span>data<span style="color: #339933;">,</span> <span style="color: #000;">&#123;</span>width<span style="color: #339933;">:</span> <span style="color: #CC0000;">500</span><span style="color: #339933;">,</span> height<span style="color: #339933;">:</span> <span style="color: #CC0000;">240</span><span style="color: #339933;">,</span> legend<span style="color: #339933;">:</span> <span style="color: #3366CC;">'bottom'</span><span style="color: #339933;">,</span> title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Click Tracks by Date'</span><span style="color: #000;">&#125;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&lt;div id='click_chart_div' style='width: 650px; height: 240px;'&gt;&lt;/div&gt;</pre></div></div>

<h4>Pie Chart</h4>
<div id="attachment_1262" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ericlamb.net/wp-content/uploads/2009/03/pie_chart1.jpg" onclick="return TrackClick('http%3A%2F%2Fblog.ericlamb.net%2Fwp-content%2Fuploads%2F2009%2F03%2Fpie_chart1.jpg','Pie+Chart')"><img src="http://blog.ericlamb.net/wp-content/uploads/2009/03/pie_chart1-300x227.jpg" alt="Pie Chart" title="Pie Chart" width="300" height="227" class="size-medium wp-image-1262" /></a><p class="wp-caption-text">Pie Chart</p></div>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
google.<span style="color: #660066;">load</span><span style="color: #000;">&#40;</span><span style="color: #3366CC;">&quot;visualization&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #339933;">,</span> <span style="color: #000;">&#123;</span>packages<span style="color: #339933;">:</span><span style="color: #000;">&#91;</span><span style="color: #3366CC;">&quot;piechart&quot;</span><span style="color: #000;">&#93;</span><span style="color: #000;">&#125;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
google.<span style="color: #660066;">setOnLoadCallback</span><span style="color: #000;">&#40;</span>drawChart<span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> drawChart<span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span> <span style="color: #000;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">visualization</span>.<span style="color: #660066;">DataTable</span><span style="color: #000;">&#40;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">addColumn</span><span style="color: #000;">&#40;</span><span style="color: #3366CC;">'string'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Day'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">addColumn</span><span style="color: #000;">&#40;</span><span style="color: #3366CC;">'number'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Clicks'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">addRows</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">7</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Monday'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">56</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Tuesday'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">93</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Wednesday'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">21</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Thursday'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">28</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Friday'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">14</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Saturday'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">17</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">6</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'Sunday'</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	data.<span style="color: #660066;">setValue</span><span style="color: #000;">&#40;</span><span style="color: #CC0000;">6</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">24</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> chart <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> google.<span style="color: #660066;">visualization</span>.<span style="color: #660066;">PieChart</span><span style="color: #000;">&#40;</span>document.<span style="color: #660066;">getElementById</span><span style="color: #000;">&#40;</span><span style="color: #3366CC;">'day_chart_div'</span><span style="color: #000;">&#41;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
	chart.<span style="color: #660066;">draw</span><span style="color: #000;">&#40;</span>data<span style="color: #339933;">,</span> <span style="color: #000;">&#123;</span>width<span style="color: #339933;">:</span> <span style="color: #CC0000;">500</span><span style="color: #339933;">,</span> height<span style="color: #339933;">:</span> <span style="color: #CC0000;">400</span><span style="color: #339933;">,</span> is3D<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Clicks By Day'</span><span style="color: #339933;">,</span> backgroundColor<span style="color: #339933;">:</span> <span style="color: #3366CC;">'#f9f9f9'</span><span style="color: #339933;">,</span> legend<span style="color: #339933;">:</span> <span style="color: #3366CC;">'top'</span><span style="color: #339933;">,</span> legendBackgroundColor<span style="color: #339933;">:</span> <span style="color: #3366CC;">'#f1f1f1'</span><span style="color: #000;">&#125;</span><span style="color: #000;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.ericlamb.net/2009/03/google-visualization-api-primer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
