<?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:pullmonkey.com,2009:mephisto/</id>
  <generator uri="http://mephistoblog.com" version="0.8.0">Mephisto Drax</generator>
  <link href="http://pullmonkey.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://pullmonkey.com/" rel="alternate" type="text/html"/>
  <updated>2008-10-28T00:58:56Z</updated>
  <entry xml:base="http://pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:pullmonkey.com,2008-10-25:50497</id>
    <published>2008-10-25T05:53:00Z</published>
    <updated>2008-10-28T00:58:56Z</updated>
    <category term="Open Flash Chart Graphs"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="ruby"/>
    <link href="http://pullmonkey.com/2008/10/25/open-flash-chart-ii-updates-radar-charts-and-scatter-lines" rel="alternate" type="text/html"/>
    <title>Open Flash Chart II - Updates, Radar Charts and Scatter Lines</title>
<content type="html">
            Recently, some good work has gone into the Open Flash Chart plugin.  First, it is now up to date with &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2&quot;&gt;the official php version of OFC&lt;/a&gt;.  That means we have &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/radar-charts-menu.php&quot;&gt;Radar Charts&lt;/a&gt; and &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/scatter-line-chart.php&quot;&gt;Scatter Line&lt;/a&gt; capabilities now.&lt;br /&gt;&lt;br /&gt;
Also, some nice people have helped this plugin along to maturity.  I would like to thank &lt;a href=&quot;http://github.com/dfl&quot;&gt;David&lt;/a&gt; and &lt;a href=&quot;http://harryseldon.thinkosphere.com/&quot;&gt;Harry&lt;/a&gt; for their work.  &lt;br /&gt;
&lt;br /&gt;
David made some very much needed improvements and brought Open Flash Chart II plugin up to speed with Rails 2.x. 
So take note, this is the &amp;quot;modern&amp;quot; way to work with the charts:&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;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&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;c&quot;&gt;## EDIT dont need this line with the latest plugin.&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;#include OpenFlashChart&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;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    respond_to &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |wants|&lt;tt&gt;
&lt;/tt&gt;      wants.html {&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;, url_for( &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;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:format&lt;/span&gt; =&amp;gt; &lt;span class=&quot;sy&quot;&gt;:json&lt;/span&gt; ) )&lt;tt&gt;
&lt;/tt&gt;      }&lt;tt&gt;
&lt;/tt&gt;      wants.json { &lt;tt&gt;
&lt;/tt&gt;        &lt;span class=&quot;c&quot;&gt;# Edit:: don't do the OpenFlashChart::Base stuff anymore&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        &lt;span class=&quot;c&quot;&gt;#chart = OpenFlashChart::Base.new( :title =&amp;gt; Title.new(&amp;quot;MY TITLE&amp;quot;) ) do |c|&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        chart = &lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new( &lt;span class=&quot;sy&quot;&gt;:title&lt;/span&gt; =&amp;gt; &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;MY TITLE&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;) ) &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |c|&lt;tt&gt;
&lt;/tt&gt;          c &amp;lt;&amp;lt; &lt;span class=&quot;co&quot;&gt;BarGlass&lt;/span&gt;.new( &lt;span class=&quot;sy&quot;&gt;:values&lt;/span&gt; =&amp;gt; (&lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;..&lt;span class=&quot;i&quot;&gt;10&lt;/span&gt;).sort_by{rand} )&lt;tt&gt;
&lt;/tt&gt;        &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        render &lt;span class=&quot;sy&quot;&gt;:text&lt;/span&gt; =&amp;gt; chart, &lt;span class=&quot;sy&quot;&gt;:layout&lt;/span&gt; =&amp;gt; &lt;span class=&quot;pc&quot;&gt;false&lt;/span&gt;&lt;tt&gt;
&lt;/tt&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;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

Open Flash Chart was put in to the appropriate OpenFlashChart namespace/module, to ensure we don't run into any conflicts.  It also now takes blocks which will be helpful.  The example above is courtesy of David.
&lt;br /&gt;
&lt;br /&gt;
Harry, has done a great job of providing examples for the latest features of Open Flash Chart.&lt;br /&gt;
Check out his &lt;a href=&quot;http://harryseldon.thinkosphere.com/2008/10/23/radar-chart-example-with-ofc2&quot;&gt;Radar Chart Example&lt;/a&gt;. &lt;br /&gt;
Also, check out his &lt;a href=&quot;http://harryseldon.thinkosphere.com/2008/10/22/scatter-line-chart-example-with-ofc2&quot;&gt;Scatter Line Chart Example&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thank you for the great work guys.
&lt;br /&gt;
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:pullmonkey.com,2008-09-23:49033</id>
    <published>2008-09-23T14:13:00Z</published>
    <updated>2008-09-25T16:29:52Z</updated>
    <category term="Javascript"/>
    <category term="Open Flash Chart Graphs"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="tutorials"/>
    <link href="http://pullmonkey.com/2008/9/23/open-flash-chart-ii-javascript-part-3" rel="alternate" type="text/html"/>
    <title>Open Flash Chart II - Javascript (Part 3)</title>
<content type="html">
            This article is a follow on to &lt;a href=&quot;http://pullmonkey.com/2008/9/21/open-flash-chart-ii-javascript-part-1&quot;&gt;Part 1&lt;/a&gt; and &lt;a href=&quot;http://pullmonkey.com/2008/9/22/open-flash-chart-ii-javascript-part-2&quot;&gt;Part 2&lt;/a&gt;.  In this article, I will discuss how we can change between various charts on the fly - meaning, changing the SWFObject without rerendering the page but this time we can do it without storing everything in javascript variables initially.  We will use an Ajax request to grab our data off the server.&lt;br /&gt;&lt;br /&gt;
As promised there are still more topics to come on OFC and Javascript:&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tutorial-5.php&quot;&gt;Basics of OFC and Javascript&lt;/a&gt;. - &lt;b&gt;&lt;a href=&quot;http://pullmonkey.com/2008/9/21/open-flash-chart-ii-javascript-part-1&quot;&gt;Discussed in Part 1&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tutorial-6.php&quot;&gt;Change data on the fly with links&lt;/a&gt;. - &lt;b&gt;&lt;a href=&quot;http://pullmonkey.com/2008/9/22/open-flash-chart-ii-javascript-part-2&quot;&gt;Discussed in Part 2&lt;/a&gt;&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tutorial-js.php&quot;&gt;Update and Save data&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart/gallery-js-ajax-2.php&quot;&gt;Ajax calls to server&lt;/a&gt; - &lt;b&gt;This article&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart/gallery-js-2.php&quot;&gt;Manipulate the data through an interface&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://ext-ux-ofcgxt.googlecode.com/svn/demo/Test.html&quot;&gt;Some really cool interfaces&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Here is the graph and interface we are after in this example:&lt;br /&gt;&lt;br /&gt;
    &lt;div&gt;&lt;/div&gt;
    
    &lt;br /&gt;&lt;br /&gt;
    
      &lt;a href=&quot;#&quot;&gt;Load Original Chart (Bar Graph)&lt;/a&gt;

     || 
    
      &lt;a href=&quot;#&quot;&gt;Load Chart from server data (Line Graph)&lt;/a&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;&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;    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;MY TITLE - original&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 = &lt;span class=&quot;co&quot;&gt;BarGlass&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    bar.set_values([&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;span class=&quot;i&quot;&gt;5&lt;/span&gt;,&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;    &lt;span class=&quot;iv&quot;&gt;@chart&lt;/span&gt; = &lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@chart&lt;/span&gt;.set_title(title)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@chart&lt;/span&gt;.add_element(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;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;some_server_data&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.text = &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;Line Dot&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&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.text = &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;Line Hollow&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&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.text = &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;Line&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&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;/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;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;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;html&amp;gt;&lt;tt&gt;
&lt;/tt&gt;  &amp;lt;head&amp;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;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;swfobject&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;%&amp;gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&lt;tt&gt;
&lt;/tt&gt;  &amp;lt;/head&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;body&amp;gt;&lt;tt&gt;
&lt;/tt&gt;    &amp;lt;%= &lt;span class=&quot;iv&quot;&gt;@chart&lt;/span&gt;.js_open_flash_chart_object(&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_chart_js_1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;i&quot;&gt;550&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;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;&amp;lt;br/&amp;gt;&lt;tt&gt;
&lt;/tt&gt;    &amp;lt;%= &lt;span class=&quot;iv&quot;&gt;@chart&lt;/span&gt;.link_to_ofc_load(&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;Load Original Chart&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;my_chart_js_1&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;%= @chart.link_to_remote_ofc_load(&amp;quot;Load Chart from server data&amp;quot;, &amp;quot;my_chart_js_1&amp;quot;, &amp;quot;/test_it/some_server_data&amp;quot;) %&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;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;body&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;/span&gt;html&amp;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;
In this example, we make use of the &lt;b&gt;link_to_remote_ofc_load&lt;/b&gt; method that basically creates a &lt;i&gt;link_to_remote&lt;/i&gt; along with the function that we call to load the chart data into the swfobject chart from the server.  It takes three arguments, the link text, the id of the div whose swf we will load new data into and the url from which to fetch the data.
&lt;br /&gt;
For more information on the javascript callbacks that I setup here, you will want to view the page source and read about it further over at &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart/gallery-js-ajax-2.php&quot;&gt;teethgrinder's tutorial&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;
Good Luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:pullmonkey.com,2008-09-22:49032</id>
    <published>2008-09-22T15:17:00Z</published>
    <updated>2008-09-23T14:18:41Z</updated>
    <category term="development"/>
    <category term="Javascript"/>
    <category term="Open Flash Chart Graphs"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="ruby"/>
    <category term="tutorials"/>
    <link href="http://pullmonkey.com/2008/9/22/open-flash-chart-ii-javascript-part-2" rel="alternate" type="text/html"/>
    <title>Open Flash Chart II - Javascript (Part 2)</title>
<content type="html">
            This article is a follow on to &lt;a href=&quot;http://pullmonkey.com/2008/9/21/open-flash-chart-ii-javascript-part-1&quot;&gt;Part 1&lt;/a&gt;.  In this article, I will discuss how we can change between various charts on the fly - meaning, changing the SWFObject without sending a request or rerendering the page.&lt;br /&gt;&lt;br /&gt;
As promised there are still more topics to come on OFC and Javascript:&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tutorial-5.php&quot;&gt;Basics of OFC and Javascript&lt;/a&gt;. - &lt;b&gt;&lt;a href=&quot;http://pullmonkey.com/2008/9/21/open-flash-chart-ii-javascript-part-1&quot;&gt;Last article (part 1)&lt;/a&gt;&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tutorial-6.php&quot;&gt;Change data on the fly with links&lt;/a&gt;. - &lt;b&gt;This article&lt;/b&gt;, see links under the graph.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tutorial-js.php&quot;&gt;Update and Save data&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart/gallery-js-ajax-2.php&quot;&gt;Ajax calls to server&lt;/a&gt; - &lt;b&gt;&lt;a href=&quot;http://pullmonkey.com/2008/9/23/open-flash-chart-ii-javascript-part-3&quot;&gt;Discussed in Part 3&lt;/a&gt;&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart/gallery-js-2.php&quot;&gt;Manipulate the data through an interface&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://ext-ux-ofcgxt.googlecode.com/svn/demo/Test.html&quot;&gt;Some really cool interfaces&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Here is the graph and interface we are after in this example:&lt;br /&gt;&lt;br /&gt;
    &lt;div&gt;&lt;/div&gt;
    
    &lt;br /&gt;&lt;br /&gt;
    
      
      &lt;a href=&quot;#&quot;&gt;Load Chart 1&lt;/a&gt;

     
       || 
    
      
      &lt;a href=&quot;#&quot;&gt;Load Chart 2&lt;/a&gt;
     
       || 
    
      
      &lt;a href=&quot;#&quot;&gt;Load Chart 3&lt;/a&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;    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;MY TITLE&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 = &lt;span class=&quot;co&quot;&gt;BarGlass&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    bar.set_values([&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;span class=&quot;i&quot;&gt;5&lt;/span&gt;,&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;    chart1 = &lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    chart1.set_title(title)&lt;tt&gt;
&lt;/tt&gt;    chart1.add_element(bar)&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;MY TITLE 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;    bar = &lt;span class=&quot;co&quot;&gt;BarGlass&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    bar.set_values([&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;span class=&quot;i&quot;&gt;5&lt;/span&gt;,&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;].reverse)&lt;tt&gt;
&lt;/tt&gt;    chart2 = &lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    chart2.set_title(title)&lt;tt&gt;
&lt;/tt&gt;    chart2.add_element(bar)&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;MY TITLE - some new data&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 = &lt;span class=&quot;co&quot;&gt;BarGlass&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    bar.set_values([&lt;span class=&quot;i&quot;&gt;1&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;5&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;4&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;9&lt;/span&gt;,&lt;span class=&quot;i&quot;&gt;8&lt;/span&gt;])&lt;tt&gt;
&lt;/tt&gt;    chart3 = &lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    chart3.set_title(title)&lt;tt&gt;
&lt;/tt&gt;    chart3.add_element(bar)&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@charts&lt;/span&gt; = [chart1, chart2, chart3]&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;
&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;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;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;html&amp;gt;&lt;tt&gt;
&lt;/tt&gt;  &amp;lt;head&amp;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;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;swfobject&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;%&amp;gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&lt;tt&gt;
&lt;/tt&gt;  &amp;lt;/head&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;body&amp;gt;&lt;tt&gt;
&lt;/tt&gt;    &amp;lt;%= &lt;span class=&quot;iv&quot;&gt;@charts&lt;/span&gt;.first.js_open_flash_chart_object(&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_chart_js_2&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;i&quot;&gt;550&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;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;&amp;lt;br/&amp;gt;&lt;tt&gt;
&lt;/tt&gt;    &amp;lt;% &lt;span class=&quot;iv&quot;&gt;@charts&lt;/span&gt;.each_with_index &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |chart, i| &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;%= chart.link_to_ofc_load(&amp;quot;Load Chart &lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;dl&quot;&gt;#{&lt;/span&gt;i + &lt;span class=&quot;i&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&amp;quot;, &amp;quot;my_chart_js_2&amp;quot;) %&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;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; || &lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; i &amp;lt; &lt;span class=&quot;iv&quot;&gt;@charts&lt;/span&gt;.size - &lt;span class=&quot;i&quot;&gt;1&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;% end %&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;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;body&amp;gt;&lt;tt&gt;
&lt;/tt&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;/span&gt;html&amp;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;
In this example, we make use of the &lt;b&gt;link_to_ofc_load&lt;/b&gt; method that basically creates a &lt;i&gt;link_to_function&lt;/i&gt; along with the function that we call to load the chart data into the swfobject chart.  It takes two arguments, the link text and the id of the div whose swf we will load new data into.
&lt;br /&gt;
For more information on the javascript callbacks that I setup here, you will want to view the page source and read about it further over at &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tutorial-6.php&quot;&gt;teethgrinder's tutorial&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;
Good Luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:pullmonkey.com,2008-09-21:49027</id>
    <published>2008-09-21T19:15:00Z</published>
    <updated>2008-09-23T14:17:34Z</updated>
    <category term="development"/>
    <category term="Javascript"/>
    <category term="Open Flash Chart Graphs"/>
    <category term="projects"/>
    <category term="rails"/>
    <category term="tutorials"/>
    <link href="http://pullmonkey.com/2008/9/21/open-flash-chart-ii-javascript-part-1" rel="alternate" type="text/html"/>
    <title>Open Flash Chart II - Javascript (Part 1)</title>
<content type="html">
            This article (and the work behind it -- meaning &lt;b&gt;get the latest from &lt;a href=&quot;http://github.com/pullmonkey/open_flash_chart/tree/master&quot;&gt;github&lt;/a&gt;&lt;/b&gt;) is generously sponsored by &lt;a href=&quot;http://harryseldon.thinkosphere.com/&quot;&gt;Harry Seldon&lt;/a&gt; who wants to be able to pass data around using javascript.  There are quite a few benefits to this, learn more from &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tutorial-5.php&quot;&gt;teethgrinder's tutorial on the same topic&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;
This example opens up a lot of possibilities and I thank Harry for pointing me to it.  So more to come on OFC and Javascript. For a taste of what is to come, check these out:&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tutorial-5.php&quot;&gt;The one I will go over in this article&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tutorial-6.php&quot;&gt;Change data on the fly with links&lt;/a&gt; - &lt;b&gt;&lt;a href=&quot;http://pullmonkey.com/2008/9/22/open-flash-chart-ii-javascript-part-2&quot;&gt;Discussed in Part2&lt;/a&gt;&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tutorial-js.php&quot;&gt;Update and Save data&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart/gallery-js-ajax-2.php&quot;&gt;Ajax calls to server&lt;/a&gt; - &lt;b&gt;&lt;a href=&quot;http://pullmonkey.com/2008/9/23/open-flash-chart-ii-javascript-part-3&quot;&gt;Discussed in Part 3&lt;/a&gt;&lt;/b&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart/gallery-js-2.php&quot;&gt;Manipulate the data through an interface&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://ext-ux-ofcgxt.googlecode.com/svn/demo/Test.html&quot;&gt;Some really cool interfaces&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Here is the graph we are after in this example:&lt;br /&gt;&lt;br /&gt;
    &lt;div&gt;&lt;/div&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;&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;    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;MY TITLE&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 = &lt;span class=&quot;co&quot;&gt;BarGlass&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    bar.set_values([&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;span class=&quot;i&quot;&gt;5&lt;/span&gt;,&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;    &lt;span class=&quot;iv&quot;&gt;@chart&lt;/span&gt; = &lt;span class=&quot;co&quot;&gt;OpenFlashChart&lt;/span&gt;.new&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@chart&lt;/span&gt;.set_title(title)&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@chart&lt;/span&gt;.add_element(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;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;
&lt;br /&gt;
Notice that I do not render the chart object, however I turn it into an instance variable for use in our javascript rendering of our chart.&lt;br /&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;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;html&amp;gt;&lt;tt&gt;
&lt;/tt&gt;  &amp;lt;head&amp;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;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;swfobject&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;/head&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;body&amp;gt;&lt;tt&gt;
&lt;/tt&gt;    &amp;lt;%= &lt;span class=&quot;iv&quot;&gt;@chart&lt;/span&gt;.js_open_flash_chart_object(&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_chart_js_1&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;i&quot;&gt;550&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;gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&lt;tt&gt;
&lt;/tt&gt;  &amp;lt;/body&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;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;html&amp;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;
I do a lot behind the scenes but if you look, you will see a few new things here.&lt;br /&gt;&lt;ol&gt;
&lt;li&gt;The data comes from the @chart.js_open_flash_chart_object(...) call which sets up a few javascript callback methods to send the data to the SWF object.  It  takes 3 required arguments div_name (the id of the div that houses the chart), width and height and one optional argument base_url which defaults to &quot;/&quot;.&lt;/li&gt;
&lt;li&gt;If you look at the HTML source, it is quite a bit different, we simply embed the SWF object.  We do not need to point to the data method since there actually isn't one.&lt;/li&gt;
&lt;li&gt;One difference between this Rails example and php example (from teethgrinder) is that prototype which comes standard with rails, has a JSON implementation for javascript, so we do not need the json2.js file, but make sure to include prototype.js in your apps.&lt;/li&gt;
&lt;/ol&gt;
For more information on the javascript callbacks that I setup here, you will want to view the page source and read about it further over at &lt;a href=&quot;http://teethgrinder.co.uk/open-flash-chart-2/tutorial-5.php&quot;&gt;teethgrinder's tutorial&lt;/a&gt;.
&lt;br /&gt;
&lt;br /&gt;
Good Luck! and Harry, I hope this helps, otherwise please drop me a line.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
          </content>  </entry>
  <entry xml:base="http://pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag: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://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://pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag: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://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://pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag: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://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://pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag: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://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://pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag: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://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://pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:pullmonkey.com,2008-08-01:46297</id>
    <published>2008-08-01T16:42:00Z</published>
    <updated>2008-09-19T15:25:59Z</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://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;62&lt;tt&gt;
&lt;/tt&gt;63&lt;tt&gt;
&lt;/tt&gt;64&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.text = &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;Line Dot&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&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.text = &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;Line Hollow&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&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.text = &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;Line&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&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://pullmonkey.com/">
    <author>
      <name>charlie</name>
    </author>
    <id>tag:pullmonkey.com,2008-07-30:46231</id>
    <publi