doc/classes/Lilygraph.src/M000003.html in lilygraph-0.2.5 vs doc/classes/Lilygraph.src/M000003.html in lilygraph-0.3.0

- old
+ new

@@ -8,11 +8,11 @@ <title>render (Lilygraph)</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" /> </head> <body class="standalone-code"> - <pre><span class="ruby-comment cmt"># File lib/lilygraph.rb, line 75</span> + <pre><span class="ruby-comment cmt"># File lib/lilygraph.rb, line 101</span> <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span> <span class="ruby-identifier">output</span> = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-identifier">xml</span> = <span class="ruby-constant">Builder</span><span class="ruby-operator">::</span><span class="ruby-constant">XmlMarkup</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">:target</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">output</span>, <span class="ruby-identifier">:indent</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:indent</span>]) <span class="ruby-comment cmt"># Output headers unless we specified otherwise</span> @@ -79,16 +79,29 @@ <span class="ruby-identifier">x</span> = (<span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:margin</span>][<span class="ruby-identifier">:left</span>] <span class="ruby-operator">+</span> (<span class="ruby-identifier">dx</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">data_index</span>)).<span class="ruby-identifier">round</span> <span class="ruby-comment cmt"># Rectangles</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">number</span>, <span class="ruby-identifier">number_index</span><span class="ruby-operator">|</span> - <span class="ruby-identifier">color</span> = <span class="ruby-constant">Color</span><span class="ruby-operator">::</span><span class="ruby-constant">HSL</span>.<span class="ruby-identifier">from_fraction</span>(<span class="ruby-identifier">data_index</span> <span class="ruby-operator">*</span> (<span class="ruby-value">1.0</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">size</span>),<span class="ruby-value">1.0</span>, <span class="ruby-value">0</span><span class="ruby-value">.4</span> <span class="ruby-operator">+</span> (<span class="ruby-identifier">number_index</span> <span class="ruby-operator">*</span> <span class="ruby-value">0</span><span class="ruby-value">.2</span>)).<span class="ruby-identifier">to_rgb</span> + <span class="ruby-identifier">color</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@colors</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:call</span> + <span class="ruby-ivar">@colors</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">data_index</span>, <span class="ruby-identifier">number_index</span>, <span class="ruby-ivar">@data</span>.<span class="ruby-identifier">size</span>, <span class="ruby-identifier">data</span>.<span class="ruby-identifier">size</span>) + <span class="ruby-keyword kw">elsif</span> <span class="ruby-ivar">@colors</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span> + <span class="ruby-identifier">first</span> = <span class="ruby-ivar">@colors</span>[<span class="ruby-identifier">data_index</span> <span class="ruby-operator">%</span> (<span class="ruby-ivar">@colors</span>.<span class="ruby-identifier">size</span>)] + + <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">first</span>.<span class="ruby-identifier">class</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Array</span> + <span class="ruby-identifier">first</span>[<span class="ruby-identifier">number_index</span> <span class="ruby-operator">%</span> (<span class="ruby-identifier">first</span>.<span class="ruby-identifier">size</span>)] + <span class="ruby-keyword kw">else</span> + <span class="ruby-identifier">first</span> + <span class="ruby-keyword kw">end</span> + <span class="ruby-keyword kw">else</span> + <span class="ruby-ivar">@colors</span> + <span class="ruby-keyword kw">end</span> + <span class="ruby-identifier">height</span> = ((<span class="ruby-identifier">dy</span> <span class="ruby-operator">/</span> <span class="ruby-value">10.0</span>) <span class="ruby-operator">*</span> <span class="ruby-identifier">number</span>).<span class="ruby-identifier">round</span> <span class="ruby-identifier">bar_x</span> = (<span class="ruby-identifier">x</span> <span class="ruby-operator">+</span> ((<span class="ruby-identifier">dx</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">width</span>) <span class="ruby-operator">/</span> <span class="ruby-value">2.0</span>) <span class="ruby-operator">+</span> (<span class="ruby-identifier">number_index</span> <span class="ruby-operator">*</span> <span class="ruby-identifier">bar_width</span>)).<span class="ruby-identifier">round</span> <span class="ruby-identifier">bar_y</span> = <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:viewbox</span>][<span class="ruby-identifier">:height</span>] <span class="ruby-operator">-</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:margin</span>][<span class="ruby-identifier">:bottom</span>] <span class="ruby-operator">-</span> <span class="ruby-identifier">height</span> - <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">rect</span> <span class="ruby-identifier">:fill</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">color</span>.<span class="ruby-identifier">html</span>, <span class="ruby-identifier">:stroke</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">color</span>.<span class="ruby-identifier">html</span>, <span class="ruby-value str">'stroke-width'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:x</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">bar_x</span>, <span class="ruby-identifier">:width</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">bar_width</span>, <span class="ruby-identifier">:y</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">bar_y</span>, <span class="ruby-identifier">:height</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span> + <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">rect</span> <span class="ruby-identifier">:fill</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">color</span>, <span class="ruby-identifier">:stroke</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">color</span>, <span class="ruby-value str">'stroke-width'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-identifier">:x</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">bar_x</span>, <span class="ruby-identifier">:width</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">bar_width</span>, <span class="ruby-identifier">:y</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">bar_y</span>, <span class="ruby-identifier">:height</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">height</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span> <span class="ruby-keyword kw">end</span> <span class="ruby-comment cmt"># Text</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>[<span class="ruby-identifier">:bar_text</span>] <span class="ruby-identifier">data</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">number</span>, <span class="ruby-identifier">number_index</span><span class="ruby-operator">|</span> \ No newline at end of file