<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>pullmonkey.com - Home</title>
  <id>tag:www.pullmonkey.com,2008:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://www.pullmonkey.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://www.pullmonkey.com/" rel="alternate" type="text/html"/>
  <updated>2008-08-18T17:22:09Z</updated>
  <entry xml:base="http://www.pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:www.pullmonkey.com,2008-08-18:47788</id>
    <published>2008-08-18T17:21:00Z</published>
    <updated>2008-08-18T17:22:09Z</updated>
    <category term="development"/>
    <category term="Open Flash Chart Graphs"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="tutorials"/>
    <link href="http://www.pullmonkey.com/2008/8/18/open-flash-chart-ii-point-by-point-plotting" rel="alternate" type="text/html"/>
    <title>Open Flash Chart II - Point by Point plotting</title>
<content type="html">
            Got another &lt;a href=&quot;http://pullmonkey.com/2008/8/1/open-flash-chart-ii-line-graph#comment-47780&quot;&gt;comment, this time asking about all kinds of things&lt;/a&gt;:
&lt;ol&gt;
&lt;li&gt;Plotting Points&lt;/li&gt;
&lt;li&gt;X Axis and Y Axis min and max ranges&lt;/li&gt;
&lt;li&gt;Coloring the X and Y Axis&lt;/li&gt;
&lt;li&gt;Coloring the X and Y gridlines&lt;/li&gt;
&lt;/ol&gt;
Here is the graph we are after in this example:&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;
    &amp;lt;noscript&gt;
      &amp;lt;object height=&quot;300&quot; width=&quot;600&quot;&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;embed src=&quot;/projects/open-flash-chart.swf?data=%2Fprojects%2Fopen_flash_chart2%2Fpoint_by_point&quot; height=&quot;300&quot; width=&quot;600&quot; /&gt;
      &amp;lt;/object&gt;
    &amp;lt;/noscript&gt;

&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://pullmonkey.com/projects/open_flash_chart2&quot;&gt;More Open Flash Chart II examples.&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
And here is the code (the controller):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;33&lt;tt&gt;
&lt;/tt&gt;34&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;35&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;36&lt;tt&gt;
&lt;/tt&gt;37&lt;tt&gt;
&lt;/tt&gt;38&lt;tt&gt;
&lt;/tt&gt;39&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;40&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;41&lt;tt&gt;
&lt;/tt&gt;42&lt;tt&gt;
&lt;/tt&gt;43&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;TestItController&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@graph&lt;/span&gt; = open_flash_chart_object(&lt;span class=&quot;i&quot;&gt;600&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;300&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/test_it/graph_code&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;graph_code&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    chart = &lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    title = &lt;span class=&quot;co&quot;&gt;Title&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Scatter points&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    chart.set_title(title)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    scatter = &lt;span class=&quot;co&quot;&gt;Scatter&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#FFD800&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;i&quot;&gt;10&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;# color, dot size&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    scatter.values = [&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;co&quot;&gt;ScatterValue&lt;/span&gt;.new(&lt;span class=&quot;i&quot;&gt;50&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;30&lt;/span&gt;),&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;co&quot;&gt;ScatterValue&lt;/span&gt;.new(&lt;span class=&quot;i&quot;&gt;305&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;400&lt;/span&gt;),&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;co&quot;&gt;ScatterValue&lt;/span&gt;.new(&lt;span class=&quot;i&quot;&gt;61&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;500&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;15&lt;/span&gt;),  &lt;span class=&quot;c&quot;&gt;# x, y, dot size&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;co&quot;&gt;ScatterValue&lt;/span&gt;.new(&lt;span class=&quot;i&quot;&gt;600&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;550&lt;/span&gt;),&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;co&quot;&gt;ScatterValue&lt;/span&gt;.new(&lt;span class=&quot;i&quot;&gt;459&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;300&lt;/span&gt;),&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;co&quot;&gt;ScatterValue&lt;/span&gt;.new(&lt;span class=&quot;i&quot;&gt;180&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;789&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    ]&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    chart.add_element(scatter)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    x = &lt;span class=&quot;co&quot;&gt;XAxis&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    x.set_range(&lt;span class=&quot;i&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;i&quot;&gt;650&lt;/span&gt;, &lt;span class=&quot;i&quot;&gt;100&lt;/span&gt;)  &lt;span class=&quot;c&quot;&gt;#min, max, steps&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# alternatively, you can use x.set_range(0,65000) and x.set_step(10000)&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    x.colour = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#00FF00&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# have to set the x axis labels because of scatter bug here - http://sourceforge.net/forum/message.php?msg_id=4812326&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    x.set_grid_colour(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#00F0FF&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    chart.set_x_axis(x)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    y = &lt;span class=&quot;co&quot;&gt;YAxis&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    y.set_range(&lt;span class=&quot;i&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;800&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;200&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    y.colour = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#FF0000&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    y.set_grid_colour(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#FF00FF&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    chart.set_y_axis(y)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    render &lt;span class=&quot;sy&quot;&gt;:text&lt;/span&gt; =&amp;gt; chart.to_s&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
And in your view (index.html.erb):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;script type=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; src=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/javascripts/swfobject.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;script&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= @graph %&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note&lt;/b&gt; - The X Axis is not rendering properly, this is being discussed in the &lt;a href=&quot;http://sourceforge.net/forum/?group_id=201148&quot;&gt;OFC Forums&lt;/a&gt;.
&lt;br /&gt;
Good Luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://www.pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:www.pullmonkey.com,2008-08-13:47046</id>
    <published>2008-08-13T19:15:00Z</published>
    <updated>2008-08-13T19:15:52Z</updated>
    <category term="development"/>
    <category term="rails"/>
    <category term="ruby"/>
    <link href="http://www.pullmonkey.com/2008/8/13/modularized-models-and-associations-in-activerecord" rel="alternate" type="text/html"/>
    <title>Modularized Models and Associations in ActiveRecord</title>
<content type="html">
            Have you ever encountered this error?
&lt;h2&gt;wrong constant name X::YAssociationExtension&lt;/h2&gt;
I found this error when dealing with acts_as_versioned for one my models.  I would have found it eventually with any association I would have setup in this case, so it is not acts_as_versioned's fault.&lt;br /&gt;
I have an application with various parts so I create some of my models like this:
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;./script/generate model module_name::model_name&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
So the fix is pretty simple, instead of winding up with ModuleName::ModelAssociationExtension or whatever, you want your extention module name to be ModelAssociationExtension. &lt;br /&gt;
Here is the method where the code breaks for me:&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;create_extension_modules&lt;/span&gt;(association_id, block_extension, extensions)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; block_extension&lt;tt&gt;
&lt;/tt&gt;    extension_module_name = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;pc&quot;&gt;self&lt;/span&gt;.to_s&lt;span class=&quot;dl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;#{&lt;/span&gt;association_id.to_s.camelize&lt;span class=&quot;dl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;AssociationExtension&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    silence_warnings &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;co&quot;&gt;Object&lt;/span&gt;.const_set(extension_module_name, &lt;span class=&quot;co&quot;&gt;Module&lt;/span&gt;.new(&amp;amp;block_extension))&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    Array(extensions).push(extension_module_name.constantize)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;else&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    Array(extensions)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

Here is the fix, on line 3, you will note the demodulize addition:
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;create_extension_modules&lt;/span&gt;(association_id, block_extension, extensions)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; block_extension&lt;tt&gt;
&lt;/tt&gt;    extension_module_name = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;pc&quot;&gt;self&lt;/span&gt;.to_s.demodulize&lt;span class=&quot;dl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;#{&lt;/span&gt;association_id.to_s.camelize&lt;span class=&quot;dl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;AssociationExtension&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    silence_warnings &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;co&quot;&gt;Object&lt;/span&gt;.const_set(extension_module_name, &lt;span class=&quot;co&quot;&gt;Module&lt;/span&gt;.new(&amp;amp;block_extension))&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    Array(extensions).push(extension_module_name.constantize)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;else&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    Array(extensions)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

I threw the corrected code into a library - RAILS_ROOT/lib/fix_active_record_create_extension_for_modules.rb.  Make sure to open up the necessary modules to overwrite the method itself, I.e., like this:
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;r&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;ActiveRecord&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;Associations&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;ClassMethods&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;c&quot;&gt;# the code above fits right here&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


Short and sweet, let me know if you have a better method for handling this.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://www.pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:www.pullmonkey.com,2008-08-05:46393</id>
    <published>2008-08-05T20:02:00Z</published>
    <updated>2008-08-05T20:03:42Z</updated>
    <category term="development"/>
    <category term="Open Flash Chart Graphs"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="tutorials"/>
    <link href="http://www.pullmonkey.com/2008/8/5/open-flash-chart-ii-x-axis-label-rotations" rel="alternate" type="text/html"/>
    <title>Open Flash Chart II - X Axis Label rotations</title>
<content type="html">
            Got another &lt;a href=&quot;http://pullmonkey.com/2008/8/1/open-flash-chart-ii-line-graph#comment-46391&quot;&gt;comment asking about diagonal x axis labels&lt;/a&gt;.  This example is based on &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/data-lines-2.php&quot;&gt;teethgrinder's line graph example&lt;/a&gt; and the new portions are based on &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/x-axis-labels-3.php&quot;&gt;teethgrinder's x-axis rotation example&lt;/a&gt;.  &lt;br /&gt; 

Here is the graph we are after in this example:&lt;br /&gt;

&lt;div&gt;&lt;/div&gt;
    &amp;lt;noscript&gt;
      &amp;lt;object height=&quot;300&quot; width=&quot;600&quot;&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;embed src=&quot;/projects/open-flash-chart.swf?data=%2Fprojects%2Fopen_flash_chart2%2Flines_and_x_axis_rotation&quot; height=&quot;300&quot; width=&quot;600&quot; /&gt;
      &amp;lt;/object&gt;
    &amp;lt;/noscript&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://pullmonkey.com/projects/open_flash_chart2&quot;&gt;More Open Flash Chart II examples.&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
And here is the code (the controller):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;33&lt;tt&gt;
&lt;/tt&gt;34&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;35&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;36&lt;tt&gt;
&lt;/tt&gt;37&lt;tt&gt;
&lt;/tt&gt;38&lt;tt&gt;
&lt;/tt&gt;39&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;40&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;41&lt;tt&gt;
&lt;/tt&gt;42&lt;tt&gt;
&lt;/tt&gt;43&lt;tt&gt;
&lt;/tt&gt;44&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;45&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;46&lt;tt&gt;
&lt;/tt&gt;47&lt;tt&gt;
&lt;/tt&gt;48&lt;tt&gt;
&lt;/tt&gt;49&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;50&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;51&lt;tt&gt;
&lt;/tt&gt;52&lt;tt&gt;
&lt;/tt&gt;53&lt;tt&gt;
&lt;/tt&gt;54&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;55&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;56&lt;tt&gt;
&lt;/tt&gt;57&lt;tt&gt;
&lt;/tt&gt;58&lt;tt&gt;
&lt;/tt&gt;59&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;60&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;61&lt;tt&gt;
&lt;/tt&gt;62&lt;tt&gt;
&lt;/tt&gt;63&lt;tt&gt;
&lt;/tt&gt;64&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;65&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;66&lt;tt&gt;
&lt;/tt&gt;67&lt;tt&gt;
&lt;/tt&gt;68&lt;tt&gt;
&lt;/tt&gt;69&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;70&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;71&lt;tt&gt;
&lt;/tt&gt;72&lt;tt&gt;
&lt;/tt&gt;73&lt;tt&gt;
&lt;/tt&gt;74&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;75&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;76&lt;tt&gt;
&lt;/tt&gt;77&lt;tt&gt;
&lt;/tt&gt;78&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;TestItController&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@graph&lt;/span&gt; = open_flash_chart_object(&lt;span class=&quot;i&quot;&gt;600&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;300&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/test_it/graph_code&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;graph_code&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# based on this example - http://teethgrinder.co.uk/open-flash-chart-2/data-lines-2.php&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# and parts from this example - http://teethgrinder.co.uk/open-flash-chart-2/x-axis-labels-3.php&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    title = &lt;span class=&quot;co&quot;&gt;Title&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Multiple Lines&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    data1 = []&lt;tt&gt;
&lt;/tt&gt;    data2 = []&lt;tt&gt;
&lt;/tt&gt;    data3 = []&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;i&quot;&gt;10&lt;/span&gt;.times &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |x|&lt;tt&gt;
&lt;/tt&gt;    data1 &amp;lt;&amp;lt; rand(&lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;) + &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    data2 &amp;lt;&amp;lt; rand(&lt;span class=&quot;i&quot;&gt;6&lt;/span&gt;) + &lt;span class=&quot;i&quot;&gt;7&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    data3 &amp;lt;&amp;lt; rand(&lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;) + &lt;span class=&quot;i&quot;&gt;14&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    line_dot = &lt;span class=&quot;co&quot;&gt;LineDot&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    line_dot.width = &lt;span class=&quot;i&quot;&gt;4&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line_dot.colour = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#DFC329&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line_dot.dot_size = &lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line_dot.values = data1&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    line_hollow = &lt;span class=&quot;co&quot;&gt;LineHollow&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    line_hollow.width = &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line_hollow.colour = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#6363AC&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line_hollow.dot_size = &lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line_hollow.values = data2&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    line = &lt;span class=&quot;co&quot;&gt;Line&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    line.width = &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line.colour = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#5E4725&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line.dot_size = &lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line.values = data3&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# Added these lines since the previous tutorial&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    tmp = []&lt;tt&gt;
&lt;/tt&gt;    x_labels = &lt;span class=&quot;co&quot;&gt;XAxisLabels&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    x_labels.set_vertical()&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;%w(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;one two three four five six seven eight nine ten&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;)&lt;/span&gt;&lt;/span&gt;.each &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |text|&lt;tt&gt;
&lt;/tt&gt;      tmp &amp;lt;&amp;lt; &lt;span class=&quot;co&quot;&gt;XAxisLabel&lt;/span&gt;.new(text, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#0000ff&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;diagonal&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    x_labels.labels = tmp&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    x = &lt;span class=&quot;co&quot;&gt;XAxis&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    x.set_labels(x_labels)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# new up to here ...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    y = &lt;span class=&quot;co&quot;&gt;YAxis&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    y.set_range(&lt;span class=&quot;i&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    x_legend = &lt;span class=&quot;co&quot;&gt;XLegend&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;MY X Legend&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    x_legend.set_style(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;{font-size: 20px; color: #778877}&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    y_legend = &lt;span class=&quot;co&quot;&gt;YLegend&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;MY Y Legend&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    y_legend.set_style(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;{font-size: 20px; color: #770077}&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    chart =&lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    chart.set_title(title)&lt;tt&gt;
&lt;/tt&gt;    chart.set_x_legend(x_legend)&lt;tt&gt;
&lt;/tt&gt;    chart.set_y_legend(y_legend)&lt;tt&gt;
&lt;/tt&gt;    chart.x_axis = x &lt;span class=&quot;c&quot;&gt;# Added this line since the previous tutorial&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    chart.y_axis = y&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    chart.add_element(line_dot)&lt;tt&gt;
&lt;/tt&gt;    chart.add_element(line_hollow)&lt;tt&gt;
&lt;/tt&gt;    chart.add_element(line)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    render &lt;span class=&quot;sy&quot;&gt;:text&lt;/span&gt; =&amp;gt; chart.to_s&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
And in your view (index.html.erb):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;script type=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; src=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/javascripts/swfobject.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;script&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= @graph %&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
Good Luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://www.pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:www.pullmonkey.com,2008-08-05:46375</id>
    <published>2008-08-05T04:59:00Z</published>
    <updated>2008-08-05T05:12:26Z</updated>
    <category term="development"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="tutorials"/>
    <link href="http://www.pullmonkey.com/2008/8/5/dynamic-select-boxes-many-to-many-ruby-on-rails" rel="alternate" type="text/html"/>
    <title>Dynamic Select Boxes (many to many) - Ruby on Rails</title>
<content type="html">
            I just got &lt;a href=&quot;http://pullmonkey.com/2008/3/30/dynamic-select-boxes-ruby-on-rails#comment-46369&quot;&gt;comment asking how one would go about doing a many to many relation in this dynamic select box example&lt;/a&gt;.  For example, what if an artist belongs to multiple genres. Here we go:&lt;br /&gt;
&lt;a href=&quot;http://pullmonkey.com/2008/3/30/dynamic-select-boxes-ruby-on-rails&quot;&gt;The original tutorial&lt;/a&gt;.&lt;br /&gt;
Create your models and build your migrations:
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;ruby script/generate model genre name&lt;span class=&quot;sy&quot;&gt;:string&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;ruby script/generate model artist name&lt;span class=&quot;sy&quot;&gt;:string&lt;/span&gt;   &lt;span class=&quot;c&quot;&gt;# no genre_id here, moved to association table&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;ruby script/generate model song title&lt;span class=&quot;sy&quot;&gt;:string&lt;/span&gt; artist_id&lt;span class=&quot;sy&quot;&gt;:integer&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;ruby script/generate model artist_association artist_id&lt;span class=&quot;sy&quot;&gt;:integer&lt;/span&gt; genre_id&lt;span class=&quot;sy&quot;&gt;:integer&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


Populate your genres, artists and songs through a migration:
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;ruby script/generate migration create_hierarchy&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


Contents of migration:
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;33&lt;tt&gt;
&lt;/tt&gt;34&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;35&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;36&lt;tt&gt;
&lt;/tt&gt;37&lt;tt&gt;
&lt;/tt&gt;38&lt;tt&gt;
&lt;/tt&gt;39&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;40&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;41&lt;tt&gt;
&lt;/tt&gt;42&lt;tt&gt;
&lt;/tt&gt;43&lt;tt&gt;
&lt;/tt&gt;44&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;45&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;46&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;CreateHierarchy&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ActiveRecord&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Migration&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;self&lt;/span&gt;.up&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# same genres as before&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    g1 = &lt;span class=&quot;co&quot;&gt;Genre&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Genre 1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    g2 = &lt;span class=&quot;co&quot;&gt;Genre&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Genre 2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    g3 = &lt;span class=&quot;co&quot;&gt;Genre&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Genre 3&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# same artists as before, but without a genre_id&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    a1 = &lt;span class=&quot;co&quot;&gt;Artist&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Artist 1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    a2 = &lt;span class=&quot;co&quot;&gt;Artist&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Artist 2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    a3 = &lt;span class=&quot;co&quot;&gt;Artist&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Artist 3&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    a4 = &lt;span class=&quot;co&quot;&gt;Artist&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Artist 4&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    a5 = &lt;span class=&quot;co&quot;&gt;Artist&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Artist 5&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    a6 = &lt;span class=&quot;co&quot;&gt;Artist&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Artist 6&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# now set which artists belong to which genres&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# Artist 1 belongs to all three genres&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;ArtistAssociation&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:genre_id&lt;/span&gt; =&amp;gt; g1.id, &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a1.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;ArtistAssociation&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:genre_id&lt;/span&gt; =&amp;gt; g2.id, &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a1.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;ArtistAssociation&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:genre_id&lt;/span&gt; =&amp;gt; g3.id, &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a1.id)&lt;tt&gt;
&lt;/tt&gt;   &lt;span class=&quot;c&quot;&gt;# the rest of the artists only belong to one association&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;ArtistAssociation&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:genre_id&lt;/span&gt; =&amp;gt; g1.id, &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a2.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;ArtistAssociation&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:genre_id&lt;/span&gt; =&amp;gt; g2.id, &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a3.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;ArtistAssociation&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:genre_id&lt;/span&gt; =&amp;gt; g2.id, &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a4.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;ArtistAssociation&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:genre_id&lt;/span&gt; =&amp;gt; g3.id, &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a5.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;ArtistAssociation&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:genre_id&lt;/span&gt; =&amp;gt; g3.id, &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a6.id)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Song 1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,  &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a1.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Song 2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,  &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a1.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Song 3&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,  &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a2.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Song 4&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,  &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a2.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Song 5&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,  &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a3.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Song 6&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,  &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a3.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Song 7&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,  &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a4.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Song 8&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,  &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a4.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Song 9&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,  &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a5.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Song 10&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a5.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Song 11&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a6.id)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Song 12&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt; =&amp;gt; a6.id)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;pc&quot;&gt;self&lt;/span&gt;.down&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;c&quot;&gt;# you can fill this in if you want.&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


So now we need to populate the database:
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;rake db&lt;span class=&quot;sy&quot;&gt;:migrate&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


Now we need to modify our models to set up the associations.
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;Genre&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ActiveRecord&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Base&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  has_many &lt;span class=&quot;sy&quot;&gt;:artist_associations&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  has_many &lt;span class=&quot;sy&quot;&gt;:artists&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:through&lt;/span&gt; =&amp;gt; &lt;span class=&quot;sy&quot;&gt;:artist_associations&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# CAN&amp;quot;T NEST HMTs .....  has_many :songs, :through =&amp;gt; :artists&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# do it by hand ... argh&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;songs&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    artists.map{|a| a.songs}.flatten&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;Artist&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ActiveRecord&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Base&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  has_many &lt;span class=&quot;sy&quot;&gt;:artist_associations&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  has_many &lt;span class=&quot;sy&quot;&gt;:genres&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:through&lt;/span&gt; =&amp;gt; &lt;span class=&quot;sy&quot;&gt;:artist_associations&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  has_many &lt;span class=&quot;sy&quot;&gt;:songs&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;ArtistAssociation&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ActiveRecord&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Base&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  belongs_to &lt;span class=&quot;sy&quot;&gt;:artist&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  belongs_to &lt;span class=&quot;sy&quot;&gt;:genre&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


That should be it for the many to many relationship.&lt;br /&gt;
&lt;br /&gt;
Everything else is the same as in &lt;a href=&quot;http://pullmonkey.com/2008/3/30/dynamic-select-boxes-ruby-on-rails&quot;&gt;the last tutorial&lt;/a&gt;.&lt;br /&gt;
# the controller
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;TestItController&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@genres&lt;/span&gt;  = &lt;span class=&quot;co&quot;&gt;Genre&lt;/span&gt;.find(&lt;span class=&quot;sy&quot;&gt;:all&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@artists&lt;/span&gt; = &lt;span class=&quot;co&quot;&gt;Artist&lt;/span&gt;.find(&lt;span class=&quot;sy&quot;&gt;:all&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@songs&lt;/span&gt;   = &lt;span class=&quot;co&quot;&gt;Song&lt;/span&gt;.find(&lt;span class=&quot;sy&quot;&gt;:all&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;update_artists&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# updates artists and songs based on genre selected&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    genre = &lt;span class=&quot;co&quot;&gt;Genre&lt;/span&gt;.find(params[&lt;span class=&quot;sy&quot;&gt;:genre_id&lt;/span&gt;])&lt;tt&gt;
&lt;/tt&gt;    artists = genre.artists&lt;tt&gt;
&lt;/tt&gt;    songs   = genre.songs&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    render &lt;span class=&quot;sy&quot;&gt;:update&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |page|&lt;tt&gt;
&lt;/tt&gt;      page.replace_html &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;artists&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:partial&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;artists&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:object&lt;/span&gt; =&amp;gt; artists&lt;tt&gt;
&lt;/tt&gt;      page.replace_html &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;songs&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,   &lt;span class=&quot;sy&quot;&gt;:partial&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;songs&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,   &lt;span class=&quot;sy&quot;&gt;:object&lt;/span&gt; =&amp;gt; songs&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;update_songs&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# updates songs based on artist selected&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    artist = &lt;span class=&quot;co&quot;&gt;Artist&lt;/span&gt;.find(params[&lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt;])&lt;tt&gt;
&lt;/tt&gt;    songs  = artist.songs&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    render &lt;span class=&quot;sy&quot;&gt;:update&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |page|&lt;tt&gt;
&lt;/tt&gt;      page.replace_html &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;songs&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:partial&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;songs&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:object&lt;/span&gt; =&amp;gt; songs&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;



Now as far as views go we have one view (index.html.erb) and two partials (_songs and _artists).  Let's take a look at those:&lt;br /&gt;
# the _songs partial (_songs.html.erb):
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= collection_select(&lt;span class=&quot;pc&quot;&gt;nil&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:song_id&lt;/span&gt;, songs, &lt;span class=&quot;sy&quot;&gt;:id&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;                     {&lt;span class=&quot;sy&quot;&gt;:prompt&lt;/span&gt;   =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Select a Song&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}) &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


# the _artists partial (_artists.html.erb):
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= collection_select(&lt;span class=&quot;pc&quot;&gt;nil&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:artist_id&lt;/span&gt;, artists, &lt;span class=&quot;sy&quot;&gt;:id&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:name&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;                     {&lt;span class=&quot;sy&quot;&gt;:prompt&lt;/span&gt;   =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Select an Artist&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;},&lt;tt&gt;
&lt;/tt&gt;                     {&lt;span class=&quot;sy&quot;&gt;:onchange&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;#{&lt;/span&gt;remote_function(&lt;span class=&quot;sy&quot;&gt;:url&lt;/span&gt;  =&amp;gt; {&lt;span class=&quot;sy&quot;&gt;:action&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;update_songs&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;},&lt;tt&gt;
&lt;/tt&gt;                                                      &lt;span class=&quot;sy&quot;&gt;:with&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;'artist_id='+value&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;span class=&quot;dl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}) &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;br/&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


# and last, but not least, the index view (index.html.erb):
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= javascript_include_tag &lt;span class=&quot;sy&quot;&gt;:defaults&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= collection_select(nil, :genre_id,  @genres,  :id, :name,&lt;tt&gt;
&lt;/tt&gt;                      {:prompt   =&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Select a Genre&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;},&lt;tt&gt;
&lt;/tt&gt;                      {&lt;span class=&quot;sy&quot;&gt;:onchange&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;#{&lt;/span&gt;remote_function(&lt;span class=&quot;sy&quot;&gt;:url&lt;/span&gt;  =&amp;gt; {&lt;span class=&quot;sy&quot;&gt;:action&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;update_artists&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;},&lt;tt&gt;
&lt;/tt&gt;                                                       &lt;span class=&quot;sy&quot;&gt;:with&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;'genre_id='+value&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;span class=&quot;dl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}) &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;br/&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;div id=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;artists&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt;&amp;lt;%= render &lt;span class=&quot;sy&quot;&gt;:partial&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;artists&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:object&lt;/span&gt; =&amp;gt; &lt;span class=&quot;iv&quot;&gt;@artists&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&amp;lt;/div&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;div id=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;songs&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt;&amp;lt;%= render &lt;span class=&quot;sy&quot;&gt;:partial&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;songs&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,   &lt;span class=&quot;sy&quot;&gt;:object&lt;/span&gt; =&amp;gt; &lt;span class=&quot;iv&quot;&gt;@songs&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&amp;lt;/div&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;br /&gt;&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://www.pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:www.pullmonkey.com,2008-08-04:46367</id>
    <published>2008-08-04T16:56:00Z</published>
    <updated>2008-08-04T16:58:11Z</updated>
    <category term="development"/>
    <category term="Open Flash Chart Graphs"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="tutorials"/>
    <link href="http://www.pullmonkey.com/2008/8/4/open-flash-chart-ii-multiple-graphs-on-the-same-page" rel="alternate" type="text/html"/>
    <title>Open Flash Chart II - Multiple graphs on the same page</title>
<content type="html">
            Got a &lt;a href=&quot;http://pullmonkey.com/2008/7/29/open-flash-chart-ii-pie-chart#comment-46358&quot;&gt;comment asking about multiple graphs on the same page and if you need another controller or how that would all work&lt;/a&gt;.  You only need one controller if you are going to have different graphs in the same view.&lt;br /&gt; 
No graph for this example, just the code.&lt;br /&gt;
&lt;a href=&quot;http://pullmonkey.com/projects/open_flash_chart2&quot;&gt;Open Flash Chart II examples.&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
Here is the code (the controller):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;TestItController&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@graph1&lt;/span&gt; = open_flash_chart_object(&lt;span class=&quot;i&quot;&gt;600&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;300&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/test_it/graph_one&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@graph2&lt;/span&gt; = open_flash_chart_object(&lt;span class=&quot;i&quot;&gt;600&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;300&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/test_it/graph_two&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@graph3&lt;/span&gt; = open_flash_chart_object(&lt;span class=&quot;i&quot;&gt;600&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;300&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/test_it/graph_three&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# and so on ...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;graph_one&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    ...  &lt;span class=&quot;c&quot;&gt;# put some OFC2 code here like in my examples&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;graph_two&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    ...  &lt;span class=&quot;c&quot;&gt;# put some OFC2 code here&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;graph_three&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    ...  &lt;span class=&quot;c&quot;&gt;# put some OFC2 code here&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
And in your view (index.html.erb):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;script type=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; src=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/javascripts/swfobject.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;script&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= @graph1 %&amp;gt;&amp;lt;br&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= &lt;span class=&quot;iv&quot;&gt;@graph2&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&amp;lt;br/&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= &lt;span class=&quot;iv&quot;&gt;@graph3&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&amp;lt;br/&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
Good Luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://www.pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:www.pullmonkey.com,2008-08-01:46297</id>
    <published>2008-08-01T16:42:00Z</published>
    <updated>2008-08-01T22:31:08Z</updated>
    <category term="development"/>
    <category term="Open Flash Chart Graphs"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="tutorials"/>
    <link href="http://www.pullmonkey.com/2008/8/1/open-flash-chart-ii-line-graph" rel="alternate" type="text/html"/>
    <title>Open Flash Chart II - Line Graph</title>
<content type="html">
            Got another &lt;a href=&quot;http://pullmonkey.com/2008/7/23/open-flash-chart-ii-plugin-for-ruby-on-rails-ofc2#comment-46271&quot;&gt;comment asking about creating a line graph&lt;/a&gt;.  This example is based on &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/data-lines-2.php&quot;&gt;teethgrinder's line graph example&lt;/a&gt;.  &lt;br /&gt; 

Here is the graph we are after in this example:&lt;br /&gt;

&lt;div&gt;&lt;/div&gt;
    &amp;lt;noscript&gt;
      &amp;lt;object height=&quot;300&quot; width=&quot;600&quot;&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;embed src=&quot;/projects/open-flash-chart.swf?data=%2Fprojects%2Fopen_flash_chart2%2Flines&quot; height=&quot;300&quot; width=&quot;600&quot; /&gt;
      &amp;lt;/object&gt;
    &amp;lt;/noscript&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://pullmonkey.com/projects/open_flash_chart2&quot;&gt;More Open Flash Chart II examples.&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
And here is the code (the controller):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;33&lt;tt&gt;
&lt;/tt&gt;34&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;35&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;36&lt;tt&gt;
&lt;/tt&gt;37&lt;tt&gt;
&lt;/tt&gt;38&lt;tt&gt;
&lt;/tt&gt;39&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;40&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;41&lt;tt&gt;
&lt;/tt&gt;42&lt;tt&gt;
&lt;/tt&gt;43&lt;tt&gt;
&lt;/tt&gt;44&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;45&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;46&lt;tt&gt;
&lt;/tt&gt;47&lt;tt&gt;
&lt;/tt&gt;48&lt;tt&gt;
&lt;/tt&gt;49&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;50&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;51&lt;tt&gt;
&lt;/tt&gt;52&lt;tt&gt;
&lt;/tt&gt;53&lt;tt&gt;
&lt;/tt&gt;54&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;55&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;56&lt;tt&gt;
&lt;/tt&gt;57&lt;tt&gt;
&lt;/tt&gt;58&lt;tt&gt;
&lt;/tt&gt;59&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;60&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;61&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;TestItController&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@graph&lt;/span&gt; = open_flash_chart_object(&lt;span class=&quot;i&quot;&gt;600&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;300&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/test_it/graph_code&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;graph_code&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# based on this example - http://teethgrinder.co.uk/open-flash-chart-2/data-lines-2.php&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    title = &lt;span class=&quot;co&quot;&gt;Title&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Multiple Lines&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    data1 = []&lt;tt&gt;
&lt;/tt&gt;    data2 = []&lt;tt&gt;
&lt;/tt&gt;    data3 = []&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;i&quot;&gt;10&lt;/span&gt;.times &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |x|&lt;tt&gt;
&lt;/tt&gt;      data1 &amp;lt;&amp;lt; rand(&lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;) + &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      data2 &amp;lt;&amp;lt; rand(&lt;span class=&quot;i&quot;&gt;6&lt;/span&gt;) + &lt;span class=&quot;i&quot;&gt;7&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      data3 &amp;lt;&amp;lt; rand(&lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;) + &lt;span class=&quot;i&quot;&gt;14&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    line_dot = &lt;span class=&quot;co&quot;&gt;LineDot&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    line_dot.width = &lt;span class=&quot;i&quot;&gt;4&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line_dot.colour = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#DFC329&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line_dot.dot_size = &lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line_dot.values = data1&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    line_hollow = &lt;span class=&quot;co&quot;&gt;LineHollow&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    line_hollow.width = &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line_hollow.colour = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#6363AC&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line_hollow.dot_size = &lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line_hollow.values = data2&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    line = &lt;span class=&quot;co&quot;&gt;Line&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    line.width = &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line.colour = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#5E4725&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line.dot_size = &lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    line.values = data3&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    y = &lt;span class=&quot;co&quot;&gt;YAxis&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    y.set_range(&lt;span class=&quot;i&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;20&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    x_legend = &lt;span class=&quot;co&quot;&gt;XLegend&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;MY X Legend&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    x_legend.set_style(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;{font-size: 20px; color: #778877}&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    y_legend = &lt;span class=&quot;co&quot;&gt;YLegend&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;MY Y Legend&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    y_legend.set_style(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;{font-size: 20px; color: #770077}&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    chart =&lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    chart.set_title(title)&lt;tt&gt;
&lt;/tt&gt;    chart.set_x_legend(x_legend)&lt;tt&gt;
&lt;/tt&gt;    chart.set_y_legend(y_legend)&lt;tt&gt;
&lt;/tt&gt;    chart.y_axis = y&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    chart.add_element(line_dot)&lt;tt&gt;
&lt;/tt&gt;    chart.add_element(line_hollow)&lt;tt&gt;
&lt;/tt&gt;    chart.add_element(line)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    render &lt;span class=&quot;sy&quot;&gt;:text&lt;/span&gt; =&amp;gt; chart.to_s&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
And in your view (index.html.erb):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;script type=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; src=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/javascripts/swfobject.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;script&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= @graph %&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
Good Luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://www.pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:www.pullmonkey.com,2008-07-30:46231</id>
    <published>2008-07-30T15:47:00Z</published>
    <updated>2008-07-31T15:53:13Z</updated>
    <category term="development"/>
    <category term="Open Flash Chart Graphs"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="tutorials"/>
    <link href="http://www.pullmonkey.com/2008/7/30/open-flash-chart-ii-horizontal-bar-graph" rel="alternate" type="text/html"/>
    <title>Open Flash Chart II - Horizontal Bar Graph</title>
<content type="html">
            Just got another &lt;a href=&quot;http://pullmonkey.com/2008/7/23/open-flash-chart-ii-plugin-for-ruby-on-rails-ofc2#comment-46226&quot;&gt;comment asking about making a horizontal bar chart&lt;/a&gt;.  This example is based on &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/horizontal-bar-chart.php&quot;&gt;teethgrinder's horizontal bar example&lt;/a&gt;.  So you will need to get the latest plugin since this required that I add a few things as of this article.  &lt;br /&gt; 

Here is the graph we are after in this example:&lt;br /&gt;

&lt;div&gt;&lt;/div&gt;
    &amp;lt;noscript&gt;
      &amp;lt;object height=&quot;300&quot; width=&quot;600&quot;&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;embed src=&quot;/projects/open-flash-chart.swf?data=%2Fprojects%2Fopen_flash_chart2%2Fhbar&quot; height=&quot;300&quot; width=&quot;600&quot; /&gt;
      &amp;lt;/object&gt;
    &amp;lt;/noscript&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://pullmonkey.com/projects/open_flash_chart2&quot;&gt;More Open Flash Chart II examples.&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
And here is the code (the controller):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;33&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;TestItController&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@graph&lt;/span&gt; = open_flash_chart_object(&lt;span class=&quot;i&quot;&gt;600&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;300&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/test_it/graph_code&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;graph_code&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# based on this example - http://teethgrinder.co.uk/open-flash-chart-2/horizontal-bar-chart.php&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    title = &lt;span class=&quot;co&quot;&gt;Title&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;HBar Graph&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    hbar = &lt;span class=&quot;co&quot;&gt;HBar&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# could also do it one at a time with hbar.append_value(...) or&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# hbar.values &amp;lt;&amp;lt; ...&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    hbar.values = [&lt;span class=&quot;co&quot;&gt;HBarValue&lt;/span&gt;.new(&lt;span class=&quot;i&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;4&lt;/span&gt;), &lt;span class=&quot;co&quot;&gt;HBarValue&lt;/span&gt;.new(&lt;span class=&quot;i&quot;&gt;4&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;8&lt;/span&gt;), &lt;span class=&quot;co&quot;&gt;HBarValue&lt;/span&gt;.new(&lt;span class=&quot;i&quot;&gt;8&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;11&lt;/span&gt;)]&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    chart = &lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    chart.set_title(title)&lt;tt&gt;
&lt;/tt&gt;    chart.add_element(hbar)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    x = &lt;span class=&quot;co&quot;&gt;XAxis&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    x.set_offset(&lt;span class=&quot;pc&quot;&gt;false&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    x.set_labels([&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Jan&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Feb&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Mar&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Apr&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;May&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Jun&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Jul&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Aug&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Sep&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Oct&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Nov&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Dec&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;])&lt;tt&gt;
&lt;/tt&gt;    chart.set_x_axis(x)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    y = &lt;span class=&quot;co&quot;&gt;YAxis&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    y.set_offset(&lt;span class=&quot;pc&quot;&gt;true&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    y.set_labels([&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Make garden look sexy&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Paint house&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Move into house&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;])&lt;tt&gt;
&lt;/tt&gt;    chart.set_y_axis(y)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    render &lt;span class=&quot;sy&quot;&gt;:text&lt;/span&gt; =&amp;gt; chart.to_s&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
And in your view (index.html.erb):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;script type=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; src=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/javascripts/swfobject.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;script&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= @graph %&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
Good Luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://www.pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:www.pullmonkey.com,2008-07-29:46223</id>
    <published>2008-07-29T22:25:00Z</published>
    <updated>2008-07-29T22:26:27Z</updated>
    <category term="development"/>
    <category term="Open Flash Chart Graphs"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="tutorials"/>
    <link href="http://www.pullmonkey.com/2008/7/29/open-flash-chart-ii-pie-chart" rel="alternate" type="text/html"/>
    <title>Open Flash Chart II - Pie Chart</title>
<content type="html">
            Just got a &lt;a href=&quot;http://pullmonkey.com/2008/7/23/open-flash-chart-ii-plugin-for-ruby-on-rails-ofc2#comment-46222&quot;&gt;comment asking for a pie chart example&lt;/a&gt;, so here is an example.  This example is based on &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/pie-chart.php&quot;&gt;teethgrinder's pie chart example for php&lt;/a&gt;.  &lt;br /&gt; 

Here is the graph we are after in this example:&lt;br /&gt;

&lt;div&gt;&lt;/div&gt;
    &amp;lt;noscript&gt;
      &amp;lt;object height=&quot;300&quot; width=&quot;600&quot;&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;embed src=&quot;/projects/open-flash-chart.swf?data=%2Fprojects%2Fopen_flash_chart2%2Fpie_graph&quot; height=&quot;300&quot; width=&quot;600&quot; /&gt;
      &amp;lt;/object&gt;
    &amp;lt;/noscript&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://pullmonkey.com/projects/open_flash_chart2&quot;&gt;More Open Flash Chart II examples.&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
And here is the code (the controller):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;TestItController&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@graph&lt;/span&gt; = open_flash_chart_object(&lt;span class=&quot;i&quot;&gt;600&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;300&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/test_it/graph_code&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;graph_code&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# based on this example - http://teethgrinder.co.uk/open-flash-chart-2/pie-chart.php&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    title = &lt;span class=&quot;co&quot;&gt;Title&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Pie Chart Example For Chipster&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    pie = &lt;span class=&quot;co&quot;&gt;Pie&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    pie.start_angle = &lt;span class=&quot;i&quot;&gt;35&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    pie.animate = &lt;span class=&quot;pc&quot;&gt;true&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    pie.tooltip = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#val# of #total#&amp;lt;br&amp;gt;#percent# of 100%&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    pie.colours = [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#d01f3c&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#356aa0&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#C79810&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;    pie.values  = [&lt;span class=&quot;i&quot;&gt;2&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;3&lt;/span&gt;, &lt;span class=&quot;co&quot;&gt;PieValue&lt;/span&gt;.new(&lt;span class=&quot;fl&quot;&gt;6.5&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Hello (6.5)&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)]&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    chart = &lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    chart.title = title&lt;tt&gt;
&lt;/tt&gt;    chart.add_element(pie)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    chart.x_axis = &lt;span class=&quot;pc&quot;&gt;nil&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    render &lt;span class=&quot;sy&quot;&gt;:text&lt;/span&gt; =&amp;gt; chart.to_s&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
And in your view (index.html.erb):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;script type=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; src=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/javascripts/swfobject.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;script&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= @graph %&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
Good Luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://www.pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:www.pullmonkey.com,2008-07-28:46162</id>
    <published>2008-07-28T16:07:00Z</published>
    <updated>2008-07-28T16:13:26Z</updated>
    <category term="development"/>
    <category term="Open Flash Chart Graphs"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="tutorials"/>
    <link href="http://www.pullmonkey.com/2008/7/28/open-flash-chart-ii-multi-bar-graph-with-tooltips" rel="alternate" type="text/html"/>
    <title>Open Flash Chart II - multi-bar graph with tooltips</title>
<content type="html">
            Just got a &lt;a href=&quot;http://pullmonkey.com/2008/7/23/open-flash-chart-ii-plugin-for-ruby-on-rails-ofc2#comment-46145&quot;&gt;comment that says tooltips are not working properly&lt;/a&gt;, so I decided to do an example for you guys (and gals).  This example is based on &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tooltip.php&quot;&gt;teethgrinder's tooltip example&lt;/a&gt;.  &lt;br /&gt; 

Here is the graph we are after in this example:&lt;br /&gt;

&lt;div&gt;&lt;/div&gt;
    &amp;lt;noscript&gt;
      &amp;lt;object height=&quot;300&quot; width=&quot;600&quot;&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;embed src=&quot;/projects/open-flash-chart.swf?data=%2Fprojects%2Fopen_flash_chart2%2Fmulti_bar_tooltip&quot; height=&quot;300&quot; width=&quot;600&quot; /&gt;
      &amp;lt;/object&gt;
    &amp;lt;/noscript&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://pullmonkey.com/projects/open_flash_chart2&quot;&gt;More Open Flash Chart II examples.&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
And here is the code (the controller):&lt;br /&gt;
&lt;b&gt;NOTE: You will need the latest plugin and open-flash-chart.swf (as of this article) for the tooltips to register properly.&lt;/b&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;33&lt;tt&gt;
&lt;/tt&gt;34&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;35&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;36&lt;tt&gt;
&lt;/tt&gt;37&lt;tt&gt;
&lt;/tt&gt;38&lt;tt&gt;
&lt;/tt&gt;39&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;40&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;41&lt;tt&gt;
&lt;/tt&gt;42&lt;tt&gt;
&lt;/tt&gt;43&lt;tt&gt;
&lt;/tt&gt;44&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;45&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;46&lt;tt&gt;
&lt;/tt&gt;47&lt;tt&gt;
&lt;/tt&gt;48&lt;tt&gt;
&lt;/tt&gt;49&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;50&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;TestItController&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@graph&lt;/span&gt; = open_flash_chart_object(&lt;span class=&quot;i&quot;&gt;600&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;300&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/test_it/graph_code&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;graph_code&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# based on this example - http://teethgrinder.co.uk/open-flash-chart-2/tooltip.php&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    title = &lt;span class=&quot;co&quot;&gt;Title&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;MultiBar Tooltip&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    bar = &lt;span class=&quot;co&quot;&gt;Bar&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    bar.values  = [&lt;span class=&quot;i&quot;&gt;9&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;8&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;7&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;6&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;4&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;3&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;2&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;    bar.tooltip = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Title Bar l&amp;lt;br&amp;gt;val = #val#&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    bar.colour  = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#47092E&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# NOTE: you can use obj.variable=() or obj.set_variable() interchangeably&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    bar2 = &lt;span class=&quot;co&quot;&gt;Bar&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    bar2.set_tooltip(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Spoon {#val#}&amp;lt;br&amp;gt;Title Bar 2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    bar2.set_colour(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#CC2A43&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    vals = [&lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;2&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;3&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;4&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    tmp = &lt;span class=&quot;co&quot;&gt;BarValue&lt;/span&gt;.new(&lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    tmp.set_colour(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#000000&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    tmp.set_tooltip(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Spoon {#val#}&amp;lt;br&amp;gt;Title Bar 2&amp;lt;br&amp;gt;Override bar 2 tooltip&amp;lt;br&amp;gt;Special data point&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    vals &amp;lt;&amp;lt; tmp&lt;tt&gt;
&lt;/tt&gt;    vals &amp;lt;&amp;lt; [&lt;span class=&quot;i&quot;&gt;6&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;7&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;8&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;9&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;    vals = vals.flatten&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    bar2.values = vals&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    t = &lt;span class=&quot;co&quot;&gt;Tooltip&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    t.set_shadow(&lt;span class=&quot;pc&quot;&gt;false&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    t.stroke = &lt;span class=&quot;i&quot;&gt;5&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    t.colour = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#6E604F&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    t.set_background_colour(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#BDB396&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    t.set_title_style(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;{font-size: 14px; color: #CC2A43;}&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;    t.set_body_style(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;{font-size: 10px; font-weight: bold; color: #000000;}&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    chart = &lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    chart.title = title&lt;tt&gt;
&lt;/tt&gt;    chart.add_element(bar)&lt;tt&gt;
&lt;/tt&gt;    chart.add_element(bar2)&lt;tt&gt;
&lt;/tt&gt;    chart.set_tooltip(t)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    render &lt;span class=&quot;sy&quot;&gt;:text&lt;/span&gt; =&amp;gt; chart.to_s&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
And in your view (index.html.erb):&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;script type=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; src=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/javascripts/swfobject.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;script&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= @graph %&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
Good Luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://www.pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:www.pullmonkey.com,2008-07-25:45838</id>
    <published>2008-07-25T16:55:00Z</published>
    <updated>2008-07-25T17:37:19Z</updated>
    <category term="development"/>
    <category term="Open Flash Chart Graphs"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="tutorials"/>
    <link href="http://www.pullmonkey.com/2008/7/25/using-a-database-to-populate-an-open-flash-chart-graph" rel="alternate" type="text/html"/>
    <title>Using a database to populate an Open Flash Chart graph</title>
<content type="html">
            Just got &lt;a href=&quot;http://pullmonkey.com/2008/7/23/open-flash-chart-ii-plugin-for-ruby-on-rails-ofc2#comment-45837&quot;&gt;Archie Smuts comment asking how to populate a Open Flash Chart graph using results from a database&lt;/a&gt;. &lt;br /&gt;
&lt;br /&gt;
Just for reference, the code that follows represents this graph:&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;
    &amp;lt;noscript&gt;
      &amp;lt;object height=&quot;300&quot; width=&quot;600&quot;&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;param /&gt;
        &amp;lt;embed src=&quot;/projects/open-flash-chart.swf?data=%2Fprojects%2Fopen_flash_chart2%2Fusing_database&quot; height=&quot;300&quot; width=&quot;600&quot; /&gt;
      &amp;lt;/object&gt;
    &amp;lt;/noscript&gt;
&lt;br /&gt;
&lt;br /&gt;
Examples for version 2 are &lt;a href=&quot;/projects/open_flash_chart2/&quot;&gt;here&lt;/a&gt;.&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
Using the new version of Open Flash Chart, here is an example for you to follow:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Start a rails app and install the plugin per &lt;a href=&quot;http://pullmonkey.com/2008/7/23/open-flash-chart-ii-plugin-for-ruby-on-rails-ofc2&quot;&gt;these instructions&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The results table that I am working with has these rows:&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;co&quot;&gt;Result&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:student_name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Jack&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:subject&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;History&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:test_score&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;97&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;co&quot;&gt;Result&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:student_name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Jack&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:subject&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Science&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:test_score&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;85&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;co&quot;&gt;Result&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:student_name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Jill&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:subject&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;History&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:test_score&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;92&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;co&quot;&gt;Result&lt;/span&gt;.create(&lt;span class=&quot;sy&quot;&gt;:student_name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Jill&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:subject&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Science&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:test_score&lt;/span&gt; =&amp;gt; &lt;span class=&quot;i&quot;&gt;57&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;/li&gt;
&lt;li&gt;Create a controller, mine is test_it:&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;30&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;31&lt;tt&gt;
&lt;/tt&gt;32&lt;tt&gt;
&lt;/tt&gt;33&lt;tt&gt;
&lt;/tt&gt;34&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;35&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;36&lt;tt&gt;
&lt;/tt&gt;37&lt;tt&gt;
&lt;/tt&gt;38&lt;tt&gt;
&lt;/tt&gt;39&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;40&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;41&lt;tt&gt;
&lt;/tt&gt;42&lt;tt&gt;
&lt;/tt&gt;43&lt;tt&gt;
&lt;/tt&gt;44&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;45&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;46&lt;tt&gt;
&lt;/tt&gt;47&lt;tt&gt;
&lt;/tt&gt;48&lt;tt&gt;
&lt;/tt&gt;49&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;TestItController&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@graph&lt;/span&gt; = open_flash_chart_object(&lt;span class=&quot;i&quot;&gt;600&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;300&lt;/span&gt;,&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/test_it/graph_code&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;graph_code&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# we will have bars for each student subject combo&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    bars   = []&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# random colors to chose from&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    colours = [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#459a89&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#9a89f9&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# the results&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    results = &lt;span class=&quot;co&quot;&gt;Result&lt;/span&gt;.find(&lt;span class=&quot;sy&quot;&gt;:all&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# group by subject and use subject as the key&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    results.group_by(&amp;amp;&lt;span class=&quot;sy&quot;&gt;:subject&lt;/span&gt;).each &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |subject, result|&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;c&quot;&gt;# 3d bar graph, could be any bar graph though&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      bar = &lt;span class=&quot;co&quot;&gt;Bar3d&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;      bar.set_key(subject, &lt;span class=&quot;i&quot;&gt;3&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;      bar.colour = colours[bars.size]&lt;tt&gt;
&lt;/tt&gt;      bar.values = result.map(&amp;amp;&lt;span class=&quot;sy&quot;&gt;:test_score&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;      bars &amp;lt;&amp;lt; bar&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# some title&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    title = &lt;span class=&quot;co&quot;&gt;Title&lt;/span&gt;.new(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Test Results&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# labels along the x axis, just hard code for now, but you would want to dynamically do this&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    x_axis = &lt;span class=&quot;co&quot;&gt;XAxis&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    x_axis.labels = [&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Jack&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Jill&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# go to 100% since we are dealing with test results&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    y_axis = &lt;span class=&quot;co&quot;&gt;YAxis&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    y_axis.set_range(&lt;span class=&quot;i&quot;&gt;0&lt;/span&gt;, &lt;span class=&quot;i&quot;&gt;100&lt;/span&gt;, &lt;span class=&quot;i&quot;&gt;10&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;c&quot;&gt;# setup the graph&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    graph = &lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    graph.bg_colour = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#ffffcc&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    graph.title = title&lt;tt&gt;
&lt;/tt&gt;    graph.x_axis = x_axis&lt;tt&gt;
&lt;/tt&gt;    graph.y_axis = y_axis&lt;tt&gt;
&lt;/tt&gt;    graph.elements = bars&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    render &lt;span class=&quot;sy&quot;&gt;:text&lt;/span&gt; =&amp;gt; graph.to_s&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
&lt;/li&gt;
&lt;li&gt;Create a view, mine is index.html.erb for the test_it controller:&lt;br /&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td title=&quot;click to toggle&quot; class=&quot;line_numbers&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;script type=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; src=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/javascripts/swfobject.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&amp;gt;&amp;lt;&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;script&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= @graph %&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;/li&gt;
&lt;br /&gt;
Hope that helps.
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://www.pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:www.pullmonkey.com,2008-07-24:45808</id>
    <published>2008-07-24T16:19:00Z</published>
    <updated>2008-07-24T16:20:39Z</updated>
    <category term="development"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="SimpleCMS"/>
    <link href="http://www.pullmonkey.com/2008/7/24/simplecms-on-github" rel="alternate" type="text/html"/>
    <title>simpleCMS on github</title>
<content type="html">
            Moved simpleCMS over to &lt;a href=&quot;http://github.com/pullmonkey/simple_cms/tree&quot;&gt;github&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;
There were quite a few changes that were required to get it working with rails 2.1, so they are in the &lt;a href=&quot;http://github.com/pullmonkey/simple_cms/tree/master&quot;&gt;repository&lt;/a&gt; now.&lt;br /&gt;
So to install, you pretty much follow the same &lt;a href=&quot;http://pullmonkey.com/2007/12/23/simple-cms-plugin-for-ruby-on-rails&quot;&gt;instructions from before&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The only thing I have not completely resolved is the use of th