<?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/"
	>

<channel>
	<title>Make.Go.Now &#187; API</title>
	<atom:link href="http://www.make-go-now.com/category/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.make-go-now.com</link>
	<description></description>
	<pubDate>Sun, 24 Oct 2010 13:30:00 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Google Chart Builder</title>
		<link>http://www.make-go-now.com/2008/01/08/google-chart-builder/</link>
		<comments>http://www.make-go-now.com/2008/01/08/google-chart-builder/#comments</comments>
		<pubDate>Tue, 08 Jan 2008 21:50:00 +0000</pubDate>
		<dc:creator>Zan Thrash</dc:creator>
		
		<category><![CDATA[API]]></category>

		<category><![CDATA[Google]]></category>

		<category><![CDATA[Grails]]></category>

		<category><![CDATA[Groovy]]></category>

		<guid isPermaLink="false">http://www.make-go-now.com/?p=7</guid>
		<description><![CDATA[For Groovy and Grails

UPDATE: (2/4/2008) This builder has been added to the Google Charts Plugin for Grails version 0.4

UPDATE: Due to a conflict in Grails with the set closure, it has been renamed to dataSet.  The examples have been updated as well as the source code and tests.

A little while ago Google released a [...]]]></description>
			<content:encoded><![CDATA[<h3>For Groovy and Grails</h3>

<p><span style="font-weight: bold;">UPDATE:</span> (2/4/2008) This builder has been added to the <a href="http://grails.codehaus.org/Google+Chart+Plugin">Google Charts Plugin</a> for Grails version 0.4</p>

<p><strong>UPDATE</strong>: Due to a conflict in Grails with the <strong>set</strong> closure, it has been renamed to <strong>dataSet</strong>.  The examples have been updated as well as the source code and tests.</p>

<p>A little while ago Google released a their <a href="http://code.google.com/apis/chart/">Chart API</a> into the wild. It’s basically allows a client to call a RESTful url and get a PNG image back of the chart. Very cool stuff.  After playing with it for a little bit I quickly realized that this RESTful approach was both very powerful and very annoying. I primarily do web development and if I’m creating a chart I want it to be on the fly and dynamic. Injecting data and labels into a potentially long url was not my idea of a good time.</p>

<p>Enter the GoogleChartBuilder (<a href="http://zanthrash.com/GoogleChartBuilder-1.0.1.zip">Download Source</a>).
Written in <a href="http://groovy.codehaus.org/">Groovy</a> utilizing it’s fantastic <a href="http://groovy.codehaus.org/BuilderSupport">BuilderSupport</a> class.</p>

<p>Here is an example on how to create a 3D Pie Chart:
<pre style="border: 1px dashed #999999; padding: 5px; overflow: auto; color: #000000; background-color: #eeeeee; line-height: 14px; width: 100%; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px;"><span style="font-family:monospace;"><code>def chart = new GoogleChartBuilder()def textList = (1..5).toList()def result = chart.pie3DChart{size(w:350, h:200)data(encoding:'text'){ dataSet(textList)}labels{ textList.each{ label(it) }}}</code></span></pre>
The <code>result</code> will yield this url string:</p>

<p><strong>http://chart.apis.google.com/chart?cht=p3&amp;chs=350&#215;200&amp;chd=t:1,2,3,4,5&amp;chl=1|2|3|4|5</strong></p>

<p>Submit this URL and you will get the following chart:</p>

<p><a href="http://bp2.blogger.com/_iAqJMcYqklk/R4TgfmQ62WI/AAAAAAAAAAM/9Ah8IXbNHHQ/s1600-h/3DPieChart.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5153490707070769506" style="margin: 0pt 10px 10px 0pt; cursor: pointer;" src="http://bp2.blogger.com/_iAqJMcYqklk/R4TgfmQ62WI/AAAAAAAAAAM/9Ah8IXbNHHQ/s320/3DPieChart.png" border="0" alt="" /></a></p>

<p>Here is an example on how to create a Horizontal Grouped Bar Chart:
<pre style="border: 1px dashed #999999; padding: 5px; overflow: auto; color: #000000; background-color: #eeeeee; line-height: 14px; width: 100%; font-family: Andale Mono,Lucida Console,Monaco,fixed,monospace; font-size: 12px;"><span style="font-family:monospace;"><code>def chart = new GoogleChartBuilder()result = chart.barChart(['horizontal', 'grouped']){  barSize(witdth:10, space:2)  size(w:350, h:200)  title(color:808080, size:16){      row('Chart 1')      row('Sampel bar chart')  }  data(encoding:'simple'){      dataSet((1..5).toList())      dataSet((5..1).toList())  }  colors{      color('66CC00')      color('3399ff')  }  legend{      label('Joy')      label('Pain')  }  axis(left:(1..5).toList(), bottom:[])  backgrounds{      background{          solid(color:'999999')      }      area{          gradient(angle:45, start:'CCCCCC', end:'999999')      }  }}}</code></span></pre>
The <code>result</code> will yield this url string:</p>

<p><strong>http://chart.apis.google.com/chart?cht=bhg&amp;chbh=10,2&amp;chs=350&#215;200&amp;chts=808080,16&amp;
chtt=Chart+1|Sampel+bar+chart&amp;chd=s:BCDEF,FEDCB&amp;chco=66CC00,3399ff&amp;
chdl=Joy|Pain&amp;chxt=y,x&amp;chxl=0:|1|2|3|4|5&amp;chf=bg,s,999999|c,lg,45,CCCCCC,0,999999,1</strong></p>

<p>Submit this URL and you will get the following chart:
<a href="http://bp3.blogger.com/_iAqJMcYqklk/R4Tiw2Q62XI/AAAAAAAAAAU/6jtYAb16wrA/s1600-h/HorzGroupedBarChart.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5153493202446768498" style="cursor: pointer;" src="http://bp3.blogger.com/_iAqJMcYqklk/R4Tiw2Q62XI/AAAAAAAAAAU/6jtYAb16wrA/s320/HorzGroupedBarChart.png" border="0" alt="" /></a></p>

<p>Here is an example on how to create a Line Chart:</p>

<p><pre class="brush: java">
def chart = new GoogleChartBuilder()
result = chart.lineChart{
size(w:300, h:200)
title{
row(&#039;Joy vs. Pain&#039;)
}
data(encoding:&#039;extended&#039;){
dataSet([1,18,200,87,1090,44,3999])
dataSet([88,900,77,1,2998,4])
}
colors{
color(&#039;66CC00&#039;)
color(&#039;3399ff&#039;)
}
lineStyle(line1:[1,6,3])
legend{
label(&#039;Joy&#039;)
label(&#039;Pain&#039;)
}
axis(left:(1..5).toList(), bottom:[])
backgrounds{
background{
solid(color:&#039;999999&#039;)
}
area{
gradient(angle:45, start:&#039;CCCCCC&#039;, end:&#039;999999&#039;)
}
}
markers{
rangeMarker(type:&#039;horizontal&#039;, color:&#039;FF0000&#039;, start:0.75, end:0.25)
rangeMarker(type:&#039;vertical&#039;, color:&#039;0000cc&#039;, start:0.7, end:0.71)
}
}
</pre></p>

<p>The <code>result</code> will yield this url string:</p>

<p><strong>http://chart.apis.google.com/chart?cht=lc&amp;chs=300&#215;200&amp;chtt=Joy+vs.+Pain&amp;
chd=e:ABASDIBXRCAs-f,BYOEBNABu2AE&amp;chco=66CC00,3399ff&amp;chls=1,6,3&amp;
chdl=Joy|Pain&amp;chxt=y,x&amp;chxl=0:|1|2|3|4|5&amp;chf=bg,s,999999|c,lg,45,CCCCCC,0,999999,1&amp;
chm=r,FF0000,0,0.75,0.25|R,0000cc,0,0.7,0.71</strong></p>

<p>Submit this URL and you will get the following chart:
<a href="http://bp2.blogger.com/_iAqJMcYqklk/R4TkamQ62YI/AAAAAAAAAAc/S9HB86hZaYk/s1600-h/LineChart.png" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}"><img id="BLOGGER_PHOTO_ID_5153495019217934722" style="cursor: pointer;" src="http://bp2.blogger.com/_iAqJMcYqklk/R4TkamQ62YI/AAAAAAAAAAc/S9HB86hZaYk/s320/LineChart.png" border="0" alt="" /></a></p>

<p>The Google Charts API also allows for the creation of:
<ul>
    <li>Scatter Point charts.</li>
    <li>Venn Diagrams</li>
    <li>2D pie charts</li>
    <li>Vertical Stacked Bar Charts</li>
    <li>Vertical Grouped Bar Charts</li>
    <li>Horizontal Stacked Bar Chars</li>
    <li>Line XY Plot Chart</li>
</ul>
To see examples of these charts (<a href="http://zanthrash.com/GoogleChartBuilder-1.0.zip">Download the source code</a>) and run the test suite under the &#8216;test&#8217; folder.  The following tests will have examples on how to use the Google Chart Builder and will also generate HTML files (in a folder named GoogleCharts under root)that contain the URL strings.
<ul>
    <li>PieChartTest.groovy</li>
    <li>BarChartTest.groovy</li>
    <li>ScatterPlotTest.groovy</li>
    <li>VennDiagramTest.groovy</li>
    <li>LineChartTest.groovy</li>
</ul>
These</p>

<p>Documentation on the keywords that are used in the Google Chart Builder can be found in the &#8216;docs&#8217; folder or <a href="http://zanthrash.com/GoogleChartBuilder.html">here</a>.</p>

<p>As you can see the Google Charts API allows you do generate some pretty complicated charts.  However because of the RESTful nature of these charts the URLs can get out of hand very fast. My intention is to ease the pain in using this useful API.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.make-go-now.com/2008/01/08/google-chart-builder/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

