<?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>Serabe Reloaded &#187; gruff</title>
	<atom:link href="http://www.serabe.com/tag/gruff/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.serabe.com</link>
	<description>Conecto ergo sum. Non conecto ergo urgueo.</description>
	<lastBuildDate>Sun, 09 Oct 2011 21:30:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Why I like JRuby</title>
		<link>http://www.serabe.com/2008/11/07/why-i-like-jruby/</link>
		<comments>http://www.serabe.com/2008/11/07/why-i-like-jruby/#comments</comments>
		<pubDate>Fri, 07 Nov 2008 16:47:22 +0000</pubDate>
		<dc:creator>Serabe</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[JRuby]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[gruff]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[mri]]></category>
		<category><![CDATA[rmagick4j]]></category>

		<guid isPermaLink="false">http://www.serabe.com/?p=275</guid>
		<description><![CDATA[Some days ago Tom forwarded me an email from Mikael Lammentausta. Mikael found an issue with rmagick4j. Using this Mikael's script PLAIN TEXT RUBY: require 'rubygems' require 'gruff' &#160; &#160; def basic_graph&#40;&#41; &#160; &#160; g = Gruff::Line.new &#160; &#160; g.theme = &#123; &#160; &#160; &#160; :colors =&#62; &#91;'#7F0099', '#2F85ED', '#2FED09','#EC962F'], &#160; &#160; &#160; :marker_color =&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago <a href="http://www.bloglines.com/blog/ThomasEEnebo" title="Tom's blog" >Tom</a> forwarded me an email from <a rel="nofollow" href="http://blogger-mikael.blogspot.com/" title="Mikael's blog" >Mikael Lammentausta</a>. Mikael found an issue with rmagick4j. Using this Mikael's script</p>
<div class="igBar"><span id="lruby-5"><a href="#" onclick="javascript:showPlainTxt('ruby-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-5">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> 'rubygems'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> 'gruff'</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> basic_graph<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; g = Gruff::Line.<span style="color:#9900CC;">new</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; g.<span style="color:#9900CC;">theme</span> = <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; :colors =&gt; <span style="color:#006600; font-weight:bold;">&#91;</span>'<span style="color:#008000; font-style:italic;">#7F0099', '#2F85ED', '#2FED09','#EC962F'],</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; :marker_color =&gt; '<span style="color:#008000; font-style:italic;">#aaa',</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; :background_colors =&gt; <span style="color:#006600; font-weight:bold;">&#91;</span>'<span style="color:#008000; font-style:italic;">#E8E8E8','#B9FD6C']</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; g.<span style="color:#9900CC;">hide_title</span> = <span style="color:#0000FF; font-weight:bold;">true</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; g.<span style="color:#9900CC;">legend_font_size</span> = <span style="color:#006666;color:#800000;">12</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; g.<span style="color:#9900CC;">marker_font_size</span> = <span style="color:#006666;color:#800000;">16</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; g.<span style="color:#9900CC;">hide_dots</span> = <span style="color:#0000FF; font-weight:bold;">false</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">return</span> g</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> bmi<span style="color:#006600; font-weight:bold;">&#40;</span>params=<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; g = basic_graph<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; g.<span style="color:#9900CC;">y_axis_label</span> = 'BMI'</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; bmis = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;color:#800000;">24</span>.<span style="color:#006666;color:#800000;">3</span>, <span style="color:#006666;color:#800000;">23</span>.<span style="color:#006666;color:#800000;">9</span>, <span style="color:#006666;color:#800000;">23</span>.<span style="color:#006666;color:#800000;">7</span>, <span style="color:#006666;color:#800000;">23</span>.<span style="color:#006666;color:#800000;">7</span>, <span style="color:#006666;color:#800000;">23</span>.<span style="color:#006666;color:#800000;">6</span>, <span style="color:#006666;color:#800000;">23</span>.<span style="color:#006666;color:#800000;">9</span>, <span style="color:#006666;color:#800000;">23</span>.<span style="color:#006666;color:#800000;">6</span>, <span style="color:#006666;color:#800000;">23</span>.<span style="color:#006666;color:#800000;">7</span>, <span style="color:#006666;color:#800000;">23</span>.<span style="color:#006666;color:#800000;">4</span>, <span style="color:#006666;color:#800000;">23</span>.<span style="color:#006666;color:#800000;">4</span>, <span style="color:#006666;color:#800000;">23</span>.<span style="color:#006666;color:#800000;">4</span>, <span style="color:#006666;color:#800000;">22</span>.<span style="color:#006666;color:#800000;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; g.<span style="color:#9900CC;">data</span><span style="color:#006600; font-weight:bold;">&#40;</span> 'BMI', bmis <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; g.<span style="color:#9900CC;">hide_legend</span> = <span style="color:#0000FF; font-weight:bold;">true</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">return</span> g</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">g=bmi</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">g.<span style="color:#9900CC;">write</span> 'graph.<span style="color:#9900CC;">jpg</span>' </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>You get two different outputs.</p>
<div id="attachment_276" class="wp-caption alignnone" style="width: 310px"><a href="http://www.serabe.com/wp-content/uploads/2008/11/graph.jpg" ><img src="http://www.serabe.com/wp-content/uploads/2008/11/graph-300x225.jpg" alt="graph 300x225 Why I like JRuby" title="MRI-generated graph" width="300" height="225" class="size-medium wp-image-276" /></a><p class="wp-caption-text">MRI-generated</p></div>
<div id="attachment_277" class="wp-caption alignnone" style="width: 310px"><a href="http://www.serabe.com/wp-content/uploads/2008/11/graph1.jpg" ><img src="http://www.serabe.com/wp-content/uploads/2008/11/graph1-300x225.jpg" alt="graph1 300x225 Why I like JRuby" title="JRuby-generated graph" width="300" height="225" class="size-medium wp-image-277" /></a><p class="wp-caption-text">JRuby</p></div>
<p>As you may see, the numbers are wrong in JRuby... or not.</p>
<p>Looking at gruff code, I saw the problem was in the label method.</p>
<div class="igBar"><span id="lruby-6"><a href="#" onclick="javascript:showPlainTxt('ruby-6'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-6">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">def</span> label<span style="color:#006600; font-weight:bold;">&#40;</span>value<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span>@spread.<span style="color:#9900CC;">to_f</span> % @marker_count.<span style="color:#9900CC;">to_f</span> == <span style="color:#006666;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> || !@y_axis_increment.<span style="color:#0000FF; font-weight:bold;">nil</span>?</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">return</span> value.<span style="color:#9900CC;">to_i</span>.<span style="color:#9900CC;">to_s</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> @spread&gt; <span style="color:#006666;color:#800000;">10</span>.<span style="color:#006666;color:#800000;">0</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">sprintf</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"%0i"</span>, value<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">elsif</span> @spread&gt;= <span style="color:#006666;color:#800000;">3</span>.<span style="color:#006666;color:#800000;">0</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">sprintf</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"%0.2f"</span>, value<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">else</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; value.<span style="color:#9900CC;">to_s</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The problem can be found in line 10. With a right input, you can make</p>
<div class="igBar"><span id="lruby-7"><a href="#" onclick="javascript:showPlainTxt('ruby-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-7">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#40;</span>@spread.<span style="color:#9900CC;">to_f</span> % @marker_count.<span style="color:#9900CC;">to_f</span> == <span style="color:#006666;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> || !@y_axis_increment.<span style="color:#0000FF; font-weight:bold;">nil</span>? </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>false and have a @spread < 3.0. Then look at this code:</p>
<div class="igBar"><span id="lruby-8"><a href="#" onclick="javascript:showPlainTxt('ruby-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-8">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">i = <span style="color:#006666;color:#800000;">23</span>.<span style="color:#006666;color:#800000;">599999999999998</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">puts</span> i </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>In JRuby, you get what you expect <em>23.599999999999998</em> but, in MRI, you get <em>23.6</em>. So, that was the problem. JRuby is more precise than MRI.</p>
<p>NOTE:<br />
<em>jruby 1.1.5 (ruby 1.8.6 patchlevel 114) (2008-11-03 rev 7996) [i386-java]</em><br />
<em>ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]</em></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Why I like JRuby on Serabe Reloaded',url: 'http://www.serabe.com/2008/11/07/why-i-like-jruby/',contentID: 'post-275',suggestTags: 'gruff,jruby,mri,rmagick4j',providerName: 'Serabe Reloaded',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper.png" class="evernoteSiteMemoryButton" title="Why I like JRuby" alt="article clipper Why I like JRuby" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.serabe.com%2F2008%2F11%2F07%2Fwhy-i-like-jruby%2F&amp;title=Why%20I%20like%20JRuby" id="wpa2a_2"><img src="http://www.serabe.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="share save 171 16 Why I like JRuby"  title="Why I like JRuby" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.serabe.com/2008/11/07/why-i-like-jruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GrÃ¡ficos de radar o de araÃ±a con Gruff</title>
		<link>http://www.serabe.com/2008/03/17/graficos-de-radar-o-de-arana-con-gruff/</link>
		<comments>http://www.serabe.com/2008/03/17/graficos-de-radar-o-de-arana-con-gruff/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 22:37:45 +0000</pubDate>
		<dc:creator>Serabe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[gráfica de radar]]></category>
		<category><![CDATA[gruff]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[spider graph]]></category>

		<guid isPermaLink="false">http://www.serabe.com/2008/03/17/graficos-de-radar-o-de-arana-con-gruff/</guid>
		<description><![CDATA[Gruff es una librerÃ­a de Ruby para realizar grÃ¡ficos. Es muy simple de usar, pero para ello, primero se ha de instalar. Nada mÃ¡s fÃ¡cil: sudo gem install gruff Una vez instalado, se puede usar uno de los mÃºltiples tutoriales que hay por Internet. Yo, por mi lado, me he decidido a hacer uno de [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://nubyonrails.com/pages/gruff"  title="PÃ¡gina de Gruff">Gruff</a> es una librerÃ­a de Ruby para realizar grÃ¡ficos. Es muy simple de usar, pero para ello, primero se ha de instalar. Nada mÃ¡s fÃ¡cil:</p>
<p><code>sudo gem install gruff</code></p>
<p>Una vez instalado, se puede usar uno de los mÃºltiples tutoriales que hay por Internet. Yo, por mi lado, me he decidido a hacer uno de un grÃ¡fico aÃºn experimental: el <a rel="nofollow" href="http://en.wikipedia.org/wiki/Radar_chart"  title="Wikipedia">grÃ¡fico de radar o de araÃ±a</a>.</p>
<p>En primer lugar, importamos las librerÃ­as necesarias:</p>
<div class="igBar"><span id="lruby-13"><a href="#" onclick="javascript:showPlainTxt('ruby-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-13">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> 'rubygems'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">"gruff"</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Para seguir, creamos el objeto necesario y le damos tÃ­tulo:</p>
<div class="igBar"><span id="lruby-14"><a href="#" onclick="javascript:showPlainTxt('ruby-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-14">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">g = Gruff::Spider.<span style="color:#9900CC;">new</span> <span style="color:#006666;color:#800000;">10</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">g.<span style="color:#9900CC;">title</span> = <span style="color:#996600;">"Calificaciones"</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ahora, aÃ±adimos los datos. El primer parÃ¡metro es el nombre que va a aparecer al lado del dato en cuestiÃ³n. El segundo es un array de datos numÃ©ricos, en el caso que nos ocupa, es un simple nÃºmero. Hay un tercer parÃ¡metro opcional: el color en hexadecimal.</p>
<div class="igBar"><span id="lruby-15"><a href="#" onclick="javascript:showPlainTxt('ruby-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-15">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">g.<span style="color:#9900CC;">data</span> <span style="color:#996600;">"MatemÃ¡ticas"</span>, <span style="color:#006666;color:#800000;">8</span>.<span style="color:#006666;color:#800000;">5</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">g.<span style="color:#9900CC;">data</span> <span style="color:#996600;">"Historia"</span>, <span style="color:#006666;color:#800000;">6</span>.<span style="color:#006666;color:#800000;">7</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">g.<span style="color:#9900CC;">data</span> <span style="color:#996600;">"Lengua y Literatura"</span>, <span style="color:#006666;color:#800000;">5</span>.<span style="color:#006666;color:#800000;">3</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">g.<span style="color:#9900CC;">data</span> <span style="color:#996600;">"EduaciÃ³n FÃ­sica"</span>, <span style="color:#006666;color:#800000;">4</span>.<span style="color:#006666;color:#800000;">8</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">g.<span style="color:#9900CC;">data</span> <span style="color:#996600;">"FÃ­sica y QuÃ­mica"</span>, <span style="color:#006666;color:#800000;">8</span>.<span style="color:#006666;color:#800000;">9</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">g.<span style="color:#9900CC;">data</span> <span style="color:#996600;">"ReligiÃ³n"</span>, <span style="color:#006666;color:#800000;">10</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ahora ya sÃ³lo queda guardar la imagen, lo cual es muy fÃ¡cil. Simplemente:</p>
<div class="igBar"><span id="lruby-16"><a href="#" onclick="javascript:showPlainTxt('ruby-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">RUBY:</span>
<div id="ruby-16">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">g.<span style="color:#9900CC;">write</span><span style="color:#006600; font-weight:bold;">&#40;</span>'marks.<span style="color:#9900CC;">png</span>'<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>He aquÃ­ el resultado (algunas letras se tapan con las lÃ­neas puesto que aÃºn estÃ¡ en fase experimental):</p>
<p><a href="http://www.serabe.com/wp-content/uploads/2008/03/marks.png"  title='Resultado'><img src='http://www.serabe.com/wp-content/uploads/2008/03/marks.thumbnail.png' alt="marks.thumbnail GrÃ¡ficos de radar o de araÃ±a con Gruff"  title="GrÃ¡ficos de radar o de araÃ±a con Gruff" /></a></p>
<p>En mi mÃ¡quina, la media de ejecutarlo 100 veces es 0.32048496 segundos, el mÃ¡ximo es 0.40913s y el mÃ­nimo, 0.314553s.</p>
<p>Y eso es to, eso es to, eso es todo amigos.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'GrÃ¡ficos de radar o de araÃ±a con Gruff on Serabe Reloaded',url: 'http://www.serabe.com/2008/03/17/graficos-de-radar-o-de-arana-con-gruff/',contentID: 'post-161',suggestTags: 'gráfica de radar,gruff,Programming,programming,Ruby,spider graph',providerName: 'Serabe Reloaded',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper.png" class="evernoteSiteMemoryButton" title="GrÃ¡ficos de radar o de araÃ±a con Gruff" alt="article clipper GrÃ¡ficos de radar o de araÃ±a con Gruff" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.serabe.com%2F2008%2F03%2F17%2Fgraficos-de-radar-o-de-arana-con-gruff%2F&amp;title=Gr%C3%83%C2%A1ficos%20de%20radar%20o%20de%20ara%C3%83%C2%B1a%20con%20Gruff" id="wpa2a_4"><img src="http://www.serabe.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="share save 171 16 GrÃ¡ficos de radar o de araÃ±a con Gruff"  title="GrÃ¡ficos de radar o de araÃ±a con Gruff" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.serabe.com/2008/03/17/graficos-de-radar-o-de-arana-con-gruff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

