Ok, already, I heard ya :) The open flash chart (version 2 - OFC2) plugin is done (really just started) and it is out on github.

Examples for version 2 are here.

I rewrote the open flash chart plugin (started from scratch) to work with json like teethgrinder does here.
This time I think it is much slicker and a lot easier to work with.
I haven't tried much more than bar graphs, all the functionality is there for other types of graphs, just not tested.
Graph that this example produces:


So it is out there, and if you are willing to try it out, here is how:
  1. rails testing_ofc_2
  2. cd testing_ofc_2
  3. script/plugin install git://github.com/pullmonkey/open_flash_chart.git
  4. script/generate controller test_it
  5. Add the following to the test_it_controller.rb in RAILS_ROOT/app/controllers:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    
    
    class TestItController < ApplicationController
      def index
        @graph = open_flash_chart_object(600,300,"/test_it/graph_code")
      end
    
      def graph_code
        title = Title.new("MY TITLE")
        bar = BarGlass.new
        bar.set_values([1,2,3,4,5,6,7,8,9])
        chart = OpenFlashChart.new
        chart.set_title(title)
        chart.add_element(bar)
        render :text => chart.to_s
      end
    end
    
    
  6. Add the following to index.html.erb in RAILS_ROOT/app/views/test_it/:
    1
    2
    3
    4
    5
    
    
    <script type="text/javascript" src="/javascripts/swfobject.js"></script>
    <%= @graph %>
    
      
  7. Copy swfobject.js from the plugin's assets/ directory (will make this happen at install time later) to your RAILS_ROOT/public/javascripts directory
  8. Copy open-flash-chart.swf from the plugin's assets/ director to your RAILS_ROOT/public/ directory
  9. script/server
  10. Browse to http://localhost:3000/test_it
  11. Let me know how it goes, thanks.


170 Responses to “Open Flash Chart II Plugin for Ruby on Rails (OFC2)”

  1. Archie Smuts Says:
    I've download the plugin and it worked first time. Great work. THANK YOU! I have been looking around the PullMonkey and RailsForum sites but could not find any examples on how to link to a database (except for the old jackster example. For example I have the following columns in results table
    (student_name, subject, test_score)
    Values
    ('Jack', 'History', 85), ('Jill', 'History', 90); etc
    In ResultsController:
    def index
    @results = Result.find(:all)
    @graph = open_flash_chart_object(600,300,"/test_it/graph_code")
    end

    def graph_code
    # what goes here?
    #
    end
    Any help is greatly appreciated
    Thanks
    Archie (newbie)
  2. charlie Says:

    @Archie Smuts - Great, glad the plugin worked for you.
    I posted a database example for you to at least get started with - http://pullmonkey.com/2008/7/25/using-a-database-to-populate-an-open-flash-chart-graph

    Hope that helps.
  3. jetienne Says:
    Hi,

    I keep getting:

    "Open Flash Chart
    IO ERROR
    Loading test data
    Error #2032"

    Any idea how to debug that ?
  4. jetienne Says:
    Hi,

    I keep getting:

    "Open Flash Chart
    IO ERROR
    Loading test data
    Error #2032"

    Any idea how to debug that ?
  5. charlie Says:

    @jetienne - That usually means that the data you are pointing to is invalid, either missing or not json. If you need more help, you can post what you have.
  6. Brad Says:
    This is great! The demo works wonderfully in FireFox 3 on mac os 10.5.4, but Safari 4 dev preview throws:

    TypeError: Undefined value swfobject.js (line 5)
  7. Cecci Says:
    No me puedo hacer.. alguien habla español????? I cannot do!! Help! The graphs are not displayed
  8. Till Says:
    Beautiful! Works perfectly in Safari 3 on Mac OS 10.5.4.

    Thanks
    Till
  9. Stu Says:
    Wow, that is extremely clean. Thanks for doing this, it's an excellent contribution.

    It doesn't look like tool tips are interpreted yet, though I see them coming across in the json. I'll be keeping an eye on this project - it's definitely how I'd like to be putting charts on our app.
  10. charlie Says:

    @Stu - The tooltips were not working. Sorry about that, I fixed it and put up an example - http://pullmonkey.com/2008/7/28/open-flash-chart-ii-multi-bar-graph-with-tooltips
  11. charlie Says:

    @Brad - Thanks for the heads up. I do not have safari 4, only 3 at this time. I did a little bit of research and the error pointed to a problem in webkit ... could be possible? For now it works in FF, IE, and Safari 3, I will see about getting Safari 4. Thanks again.
  12. Chipster Says:
    Thanks a lot for all ! Could you please put an example for pie charts ?
  13. charlie Says:

    @Chipster - here is a pie chart example - http://pullmonkey.com/2008/7/29/open-flash-chart-ii-pie-chart
  14. Mukund Says:
    Can I get an example for a Horizontal Bar? I am not able to figure out the left, right parameters in the constructor and the constructor itself doesn't seem to do anything with those parameters.
  15. Victor Says:

    i accumulate all the errors :/

    Plugin not found: ["git://github.com/pullmonkey/open_flash_chart.git"]

    it's normal ?
  16. Victor Says:

    After perseverance i have the same problem of jetienne!

    the error :
    Open Flash Chart
    IO ERROR
    Loading test data
    Error #2032

    But i have follow exactly this exemple for test your plugin...

    the controleur : "migrate_controller.rb"

    class MigrateController < ApplicationController
    def view
    @graph = open_flash_chart_object(600,300,"/migrate/graph_code")
    end

    def graph_code
    title = Title.new("MY TITLE")
    bar = BarGlass.new
    bar.set_values([1,2,3,4,5,6,7,8,9])
    chart = OpenFlashChart.new
    chart.set_title(title)
    chart.add_element(bar)
    render :text => chart.to_s
    end

    end

    the view : "view.html.erb"



    <%= @graph %>

    can you tell me my errors ?
  17. charlie Says:

    @Mukund - Your example is up - http://pullmonkey.com/2008/7/30/open-flash-chart-ii-horizontal-bar-graph I had to add the HBarValue you class and the constructor to handle left and right. Thanks for bringing this to my attention. So you will need the latest plugin code.
  18. charlie Says:

    @Victor - you may be behind a firewall that does not allows access to the git port. You may also do this:
    script/plugin install http://github.com/pullmonkey/open_flash_chart.git, with port 80 instead.

    Also, can you post the outcome of navigating your browser to http://your_domain/migrate/graph_code
    This will show you the errors if you are getting any.

    Thanks.
  19. Chipster Says:
    @Victor I had the same problem i resolved by replacing in view :



    by :

    <% javascript_include_tag "swfobject" %>
  20. Chipster Says:
    Sorry, i meaned replacing the original " standard " javascript file declaration by rails tag. Hope it could help
  21. Victor Says:

    so, first

    @Charlie with the port 80 it's ok for the plugin

    @Chipster : Thx for the
    <% javascript_include_tag "swfobject" %> witch avoid me to set all the code of swfobject.js in the view :p

    and to finish @charlie : always the same error on load the flash picture after the gif loading:
    Open Flash Chart
    IO ERROR
    Loading test data
    Error #2032

    when i set directly : http://localhost:3000/migrate/graph_code the browser return me : {"elements": [{"values": [1, 2, 3, 4, 5, 6, 7, 8, 9], "type": "bar_glass"}], "title": {"text": "MY TITLE"}}

    is it normal ?

    a moment i have think, i have the solution because redmine with a plugin need a permission for the all the methode define in the controleur (in the init.rb)
    and i have put the permission for view and i have forgotten for the graph_code but after set ... always the same error :/
  22. charlie Says:

    @Victor -
    1) Right you should definitely put the javascript in the header not just the view.

    2) When going to http://localhost:3000/migrate/graph_code you are looking at the JSON that is produced and my JSON looks the same as yours (just different order, which doesn't matter):
    {"title": {"text": "MY TITLE"}, "elements": [{"type": "bar_glass", "values": [1, 2, 3, 4, 5, 6, 7, 8, 9]}]}

    3) Do you have the right open-flash-chart.swf from the assets directory of the plugin?

    4) Can you post the relevant flash object html that is produced?

    Thanks.
  23. andrew Says:
    Charlie - would you mind providing a recipe/howto for creating line graphs? I have followed your previous example for ofc version 1, and I get blank results in my view. When I try to explicitly put in object tags I get an Error #2032. Here is the output from my view:

    <html>
    <head>

    </head>
    <body>



    swfobject.embedSWF("/test-it/open-flash-chart.swf", "flash_content_1217541259.1793", "600", "300", "9.0.0", "expressInstall.swf",{"data-file":"%2Ftest_it%2Fextra_tt"});

    <noscript>
    <object height="300" width="600">
    <param />
    <param />
    <param />
    <param />
    <embed src="/test-it/open-flash-chart.swf?data=%2Ftest_it%2Fextra_tt" height="300" width="600" />
    </object>
    </noscript>


    </body>
    </html>
  24. andrew Says:
    sorry, here is my output from my view:

    <html>
    <head>

    </head>
    <body>



    swfobject.embedSWF("/test-it/open-flash-chart.swf", "flash_content_1217541259.1793", "600", "300", "9.0.0", "expressInstall.swf",{"data-file":"%2Ftest_it%2Fextra_tt"});

    <noscript>
    <object height="300" width="600">
    <param />
    <param />
    <param />
    <param />
    <embed src="/test-it/open-flash-chart.swf?data=%2Ftest_it%2Fextra_tt" height="300" width="600" />
    </object>
    </noscript>


    </body>
    </html>

  25. Victor Says:


    when i am in the case of the flash object is loaded ,this is the html return :

    view.html //

    <object height="300" width="600">
    <param />
    </object>

    1
    2 swfobject.embedSWF("/open-flash-chart.swf", "flash_content_1217574332.47648", "600", "300", "9.0.0", "expressInstall.swf",{"data-file":"%2Fmigrate%2Fgraphcode"});
    3

    <noscript> <object height="300" width="600"> <param /> <param /> <param /> <param /> <embed src="/open-flash-chart.swf?data=%2Fmigrate%2Fgraphcode" height="300" width="600" /> </object> </noscript>

  26. Victor Says:


    when i am in the case of the flash object is loaded ,this is the html return :

    view.html //

    <object height="300" width="600">
    type="application/x-shockwave-flash" data="/open-flash-chart.swf" style="visibility: visible;">
    <param />
    </object>

    1
    2 swfobject.embedSWF("/open-flash-chart.swf", "flash_content_1217574332.47648",
    "600", "300", "9.0.0", "expressInstall.swf",{"data-file":"%2Fmigrate%2Fgraphcode"});
    3

    <noscript>
    <object>
    codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
    width="600" height="300" id="chart_1.217574332476786e+9" align="middle">
    <param />
    <param />
    <param />
    <param />
    <embed src="/open-flash-chart.swf?data=%2Fmigrate%2Fgraphcode">
    quality="high" bgcolor="#FFFFFF" width="600" height="300"
    name="chart_1.217574332476786e+9" align="middle" allowScriptAccess="sameDomain"
    type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"
    id="chart_1.217574332476786e+9" /> </object> </noscript>

  27. Victor Says:
    I'm sorry for the duplicate. but your comment listenner don't display all the html code .

    i set it in this file :
    http://www.neufgiga.com/index.php?m=c9ae77e8&a=dc18f91e&share=LNK68154892bb12a8a0c
  28. charlie Says:

    @andrew - here is a line graph example - http://pullmonkey.com/2008/8/1/open-flash-chart-ii-line-graph
  29. charlie Says:

    To insert HTML/ruby/other code into the comments, you can do this:



    1
    2
    3
    4
    5
    6

    <filter:code attributes=lang="ruby">
    # change the attributes lang from ruby to html or whatever you want.
    # Put your stuff here
    # and for the line below, get rid of the space
    < /filter:code>


    That should do it ...
  30. charlie Says:

    So here is Victor's HTML:


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
     view.html //

    <object id="flash_content_1.217574723488243e+9" height="300" width="600" type="application/x-shockwave-flash" data="/open-flash-chart.swf" style="visibility: visible;">

    <param name="flashvars" value="data-file=%2Fmigrate%2Fgraphcode"/>

    </object>

    <script type="text
    /
    javascript">

    1

    2 swfobject.embedSWF(
    "
    /open-flash-chart.swf", "flash_content_1.217574723488243e+9", "600", "300", "9.0.0", "expressInstall.swf",{"data-file":"%2Fmigrate%2Fgraphcode"});

    3

    </script>

    <noscript> <object classid=
    "
    clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="600" height="300" id="chart_1217574723.48741" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="/open-flash-chart.swf?data=%2Fmigrate%2Fgraphcode" /> <param name="quality" value="high" /> <param name="bgcolor" value="#FFFFFF" /> <embed src="/open-flash-chart.swf?data=%2Fmigrate%2Fgraphcode" quality="high" bgcolor="#FFFFFF" width="600" height="300" name="chart_1217574723.48741" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" id="chart_1217574723.48741" /> </object> </noscript>

    //

  31. charlie Says:
    And for comparison with Victor's here is what I get:



    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    <div id="flash_content_1217006545.4401"></div>
    <script type="text
    /
    javascript">
    swfobject.embedSWF(
    "
    /projects/open-flash-chart.swf", "flash_content_1217006545.4401", "600", "300", "9.0.0", "expressInstall.swf",{"data-file":"%2Fprojects%2Fopen_flash_chart2%2Fbasic_starter"});
    </script>
    <noscript>
    <object classid=
    "
    clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="600" height="300" id="chart_1217006545.44007" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="movie" value="/projects/open-flash-chart.swf?data=%2Fprojects%2Fopen_flash_chart2%2Fbasic_starter" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#FFFFFF" />
    <embed src="/projects/open-flash-chart.swf?data=%2Fprojects%2Fopen_flash_chart2%2Fbasic_starter" quality="high" bgcolor="#FFFFFF" width="600" height="300" name="chart_1217006545.44007" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" id="chart_1217006545.44007" />
    </object>
    <
    /nos
    cript>

    I notice a few things:
    1) You are missing the div that the graph goes in to
    2) Numbers appear in your javascript
    3) You have two objects in your html, I have one

    Can you post your controller code for both the index and the graph_code? Are you using the plugin?
  32. Cecci Says:
    In the graphs of horizontal bars can they add lines on every bar? To do graphs Gantt? Or already there exists inside the plugin a way of doing graphs Gantt?
  33. charlie Says:

    @Cecci - can you give me an example of what you are after? Do you mean lines in terms of a grid or lines connecting each bar? Or something different? Send me a link to an image that you would like to duplicate.
  34. Gallo Says:
    I get the 2032 as well.
    If I break at the end of the action and call chart.to_s I get

    SystemStackError: stack level too deep
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_s'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_json'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_s'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_json'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_s'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_json'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_s'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_json'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_s'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_json'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_s'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_json'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_s'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_json'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_s'
    from C:/railapps/picnicdog/vendor/plugins/open_flash_chart/lib/open_flash_chart.rb:23:in `to_json'
    ... 10934 levels...
    from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-mswin32-60/lib/mongrel/command.rb:212:in `run'
    from c:/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.4-x86-mswin32-60/bin/mongrel_rails:281
    from C:/railapps/picnicdog/vendor/rails/activesupport/lib/active_support/dependencies.rb:488:in `load'
    from C:/railapps/picnicdog/vendor/rails/activesupport/lib/active_support/dependencies.rb:488:in `load'
    from C:/railapps/picnicdog/vendor/rails/activesupport/lib/active_support/dependencies.rb:342:in `new_constants_i
    n'
    from C:/railapps/picnicdog/vendor/rails/activesupport/lib/active_support/dependencies.rb:488:in `load'
    from C:/railapps/picnicdog/vendor/rails/railties/lib/commands/servers/mongrel.rb:64
    from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    from C:/railapps/picnicdog/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in `require'
    from C:/railapps/picnicdog/vendor/rails/activesupport/lib/active_support/dependencies.rb:342:in `new_constants_i
    n'
    from C:/railapps/picnicdog/vendor/rails/activesupport/lib/active_support/dependencies.rb:495:in `require'
    from C:/railapps/picnicdog/vendor/rails/railties/lib/commands/server.rb:39
    from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
    from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'

    Any advice?

  35. charlie Says:

    @Gallo, would you mind posting your code and I will see if I can help.
  36. Gallo Says:
    My code is exactly the same except I have

    @graph = open_flash_chart_object(600,300,"/weight/graph_code")

    as my controller is the "weight" controller.

    If I break right before the render call and I look at the chart object it appears fine. See below.

    irb(#<weightcontroller:0xa772914>):001:0> chart
    => #<openflashchart:0xa6da448><barglass:0xa6da4e8>],
    @title=#<title:0xa6da4fc>>
    irb(#<weightcontroller:0xa772914>):002:0>

    When I call chart.to_s I get the above error in my previous post.

    Json is working. I test converted some Active Record Objects to_json and that worked fine.

    Cheers


  37. charlie Says:

    @Gallo - you can just call chart.to_json instead if that works for you. That way you don't get in the loop with to_s.
  38. Cecci Says:
    Hello, might you see this link to see what it wanted to do? It is a graph gantt. I it must represent of equal way in code ruby and the plugin

    http://www.kabytes.com/wp-content/uploads/2007/04/gantt-project.jpg

    The information must be of a database. I wait could help me, thank you.
  39. John Says:
    Hey, i followed the install instruction, but the data is not rendering, only:
    C:\Users\John\Documents\flash\svn\data-files\data-14.txt
    appears inside the graph object.

    Any ideas?
  40. John Says:
    My fault, had an old version of open-flash-chart.swf in my public folder! :)
  41. charlie Says:

    @Cecci - I have not found a way to do what you are asking with the lines and such. I will let you know if I find anything. You might want to contact monk.e.boy - http://teethgrinder.co.uk/open-flash-chart-2/ as he is responsible for the open-flash-chart.swf, and see what he says about getting gantt charts. I think he will appreciate the suggestion.
  42. Victor Says:

    my controler :


    <filter:code>

    def view
    @graph = open_flash_chart_object(600,300,"/migrate/graphcode")
    end

    def graphcode
    title = Title.new("MY TITLE")
    bar = BarGlass.new
    bar.set_values([1,2,3,4,5,6,7,8,9])
    chart = OpenFlashChart.new
    chart.set_title(title)
    chart.add_element(bar)
    render :text => chart.to_s
    end

    < /filter:code>

    i don't understand why i have this error ...
    :(
  43. Victor Says:

    my controler :





    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16


    def view
    @graph = open_flash_chart_object(600,300,"/migrate/graphcode")
    end

    def graphcode
    title = Title.new("MY TITLE")
    bar = BarGlass.new
    bar.set_values([1,2,3,4,5,6,7,8,9])
    chart = OpenFlashChart.new
    chart.set_title(title)
    chart.add_element(bar)
    render :text => chart.to_s
    end




    i don't understand why i have this error ...
    :(

    :D
  44. charlie Says:

    @Victor - here is one thing you should try:


    1
    2
    3
    4
    5
    6
    def view
    @graph = open_flash_chart_object(600,300,"/migrate/graphcode")
    end
    def graphcode
    render :text => %'{"title": {"text": "MY TITLE"}, "elements": [{"type": "bar_glass", "values": [1, 2, 3, 4, 5, 6, 7, 8, 9]}]}'
    end

    This should help us figure out where the problem lies. My guess at this point is that you need the latest swf file and it needs to be placed in RAILS_ROOT/public.
  45. Victor Says:

    this is my html code with your controlor :



    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16

    <div id="flash_content_1.218005931023648e+9"></div>
    <script type="text
    /
    javascript">
    swfobject.embedSWF(
    "
    /open-flash-chart.swf", "flash_content_1.218005931023648e+9", "600", "300", "9.0.0", "expressInstall.swf",{"data-file":"%2Fmigrate%2Fgraphcode"});
    </script>
    <noscript>
    <object classid=
    "
    clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="600" height="300" id="chart_1.218005931022503e+9" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="movie" value="/open-flash-chart.swf?data=%2Fmigrate%2Fgraphcode" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#FFFFFF" />
    <embed src="/open-flash-chart.swf?data=%2Fmigrate%2Fgraphcode" quality="high" bgcolor="#FFFFFF" width="600" height="300" name="chart_1.218005931022503e+9" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" id="chart_1.218005931022503e+9" />
    </object>
    <
    /nos
    cript>





    and i think i have the latest swf (size : 274Ko)
    and i always the error #2032.
  46. Victor Says:

    so after test with i delete the swf of my public directory , i have always the same error , we are on the good way ...

    perhaps my plugin don't take the swf in the public directory, perhaps i will set at a another directory...

    don't forget it's a plugin witch take your plugin for graph ... perhaps it's the solution
  47. Victor Says:
    i don't understand ... if i delete the swf on the public directory , i have a flash loading ... follow by my error ...

    And if i edit in your plugin the "base=/" at the display i don't have any flash loading ... :/
    :$
  48. charlie Says:

    @Victor - interesting. Do you have javascript enabled? Try removing one or the other section. I.e., remove the script javascript portion or the noscript portion and let me know the results.
  49. Victor Says:
    So first for my motivation i have test the plugin in a project directly ... YES it's works, lol
    i'm not a looser...

    with my plugin i have make your test , if i remove the javascript portion or the noscript portion ( in your open_flash_chart_object.rb if i have understand has you want)i haven't a swf loaded :/

  50. charlie Says:

    @Victor - perfect, so it works in a project, may I ask how you were using it before using the "plugin in a project directly?"

    And for the test, I really just thought you could bypass the use of the plugin (trying to narrow down the problem) and just copy your html (that you provided above) directly in to your view then remove one (javascript) or the other (noscript) portion and see how it goes.
  51. talapoku Says:
    In your opinion, what's the best movie ever created?
  52. Victor Says:

    OOps
    i had forget to re make the swf in the public directory for the test witch remove javascript portion or noscript

    so i re test: if the javascript are removed , no swf are loaded , but if i remove the noscript portion tht swf are loaded and the error are display :/

    I'm sorry for my bad manipulation witch reappraisal the possible solution
  53. charlie Says:

    @Victor - let's start simple:
    1) Create a controller (TestIt):
    ./script/generate controller test_it
    2) Add the action test_one() to the controller
    3) Copy this code to test_one():


    1
    2
    3
    def test_one
    render :text => %'{"title": {"text": "MY TITLE"}, "elements": [{"type": "bar_glass", "values": [1, 2, 3, 4, 5, 6, 7, 8, 9]}]}'
    end


    4) Make sure open-flash-chart.swf is in your RAILS_ROOT/public directory
    5) Make sure swfobject.js is in your RAILS_ROOT/public/javascripts directory
    6) Note: You don't need the plugin installed at all for this, since we are creating the JSON by hand.
    7) Create a view (index.html.erb) under RAILS_ROOT/app/views/test_it/ like this:


    1
    2
    3
    4
    <div id="flash_content"></div>
    <script type="text
    /
    javascript">
    swfobject.embedSWF(
    "
    /open-flash-chart.swf", "flash_content", "600", "300", "9.0.0", "expressInstall.swf",{"data-file":"%2Ftest_it%2Ftest_one"});
    </script>


    8) Browse to http://yourdomain/test_it/test_one - you should see the JSON that we manually entered
    9) Browse to http://yourdomain/test_it - you should see glass bar graphs

    Let me know.
  54. charlie Says:

    @Victor - also, some good things to know:
    1) What browser?
    2) What OS?
    3) Shouldn't matter for the example above, but what versions of rails and ruby?
  55. Victor Says:

    @Charlie

    For your test , i make a new project or i test it on my plugin of redmine ?

    so 1/FF 3
    2/Windows XP
    3/ruby 1.8.6 & rails 2.0.2
  56. charlie Says:

    @Victor - Both - in a new project just as a base case then in your plugin of redmine.
  57. Gallo Says:
    Charlie,
    If I insert the json manually in the graph_code method the chart shows fine.

    Hence the problem is the call that converts the openflashchart object to json.

    What are you using to convert it to Json. I have the json gem installed as one of my other plugins requries it.

    Thoughts?
  58. Victor Says:

    so first: in a new project , i have the JSON that we manually entered but i shouldn't see glass bar graphs for http://yourdomain/test_it :/

    in my plugin, i always have the JSON but for the graph i have this error : ArgumentError in MigrateController#index

    A copy of ApplicationController has been removed from the module tree but is still active!

    RAILS_ROOT: D:/Service/Profiles/vleboucher.BDOM/Mes documents/NetBeansProjects/Redmine/Victor/Redmine
    Application Trace | Framework Trace | Full Trace

    vendor/rails/activesupport/lib/active_support/dependencies.rb:237:in `load_missing_constant'
    vendor/rails/activesupport/lib/active_support/dependencies.rb:469:in `const_missing'
    app/controllers/application.rb:35:in `user_setup'
    :1:in `start'

    :(
  59. charlie Says:

    @Gallo - I am just using obj.to_json. You should not require a plugin to do this. So what is the name of the plugin you are using to JSON?
  60. charlie Says:

    @Victor - This may help - http://www.ruby-forum.com/topic/134839 it is a few months old, but seems to fit your problem for redmine.

    As far as your first statement that you should not see the glass bar graph - could you clarify what you mean for me?
  61. Victor Says:

    I haven't find a help in your URL :(

    what do you want i clarify ? i don't understand do you want :/
  62. charlie Says:

    @Victor - Sorry, it was worth a shot.

    And ... I need clarification on this:
    "so first: in a new project , i have the JSON that we manually entered but i shouldn't see glass bar graphs for http://yourdomain/test_it :/"

    It seems to me that you are saying that you entered in JSON manually and do not think that you should see the graph. But you actually should see the graph with just the JSON itself.
  63. Christoffer Says:
    I have followed your recipe here, except that the automatic download/install didnt work so I had to download manually and do :
    rake open_flash_chart_2:install
    (The mentioned .js and .swf files above seems to have appeared in their correct locations)

    When trying to acess my rails application in the web browser I get the following error:

    undefined method `open_flash_chart_object' for #<testcontroller:0x37c8c1c>
    app/controllers/test_controller.rb:4:in `index'

    Do you have any idea what might be causing this error?
    Do I need to require a gem somewhere in my code?
    (I have installed the json and haml gems which where mentioned somewhere to be required)
  64. Christoffer Says:
    I think you can disregard my last post. Amazingly, it seems like I've installed someone else's flash chart rails plugin (korin), and then navigated to your page for tutorials on using it... :/

    Anyway, the automatic git install simply isnt working for me (fatal: unable to connect a socket), so I manually downloaded the zip file from the github, unzipped it to the plugins folder and copied the two mentioned files to their destinations manually. I again tried to run the application, and I got the following error:

    undefined local variable or method `protocol' for #<testcontroller:0x2c34748>

    So I removed the mentions of #protocol in the open_flash_chart_object.rb file, ran the application again and the chart finally was displayed in all its beauty!

    So the moral of it might be that it would be very nice if you would also make a recipe for installing open flash chart II using a manual download.
    Anyway, thanks for the great work!
  65. charlie Says:

    @Christopher - you may be behind a firewall and just need to replace git://github... with http://github... so that you install over port 80. Give that a shot.
  66. charlie Says:

    @Christopher - I removed the protocol variable on accident :( Added it back, thanks for the catch.
  67. Totem Says:
    Hi Charlie, thanks a lot for your work.
    I've tried getting the first graph to show up, but I'm not able to. I don't get anything on the browser, and there's a "Done, with errors" in Internet Exploder, and the info is:

    Line: 6
    Char: 6921
    Error: Invalid argument.
    Code: 0
    URL: http://localhost:3002/main

    There's no error/warning messages in the web browser's output.

    Any ideas?

    My controller is 'main':



    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18

    class MainController < ApplicationController

    def index
    @graph = open_flash_chart_object(600,300,"/main/graph_code")
    end

    def graph_code
    title = Title.new("My test")
    bar = BarGlass.new
    bar.set_values([1,2,3,4,5,6,7,8,9])
    chart = OpenFlashChart.new
    chart.set_title(title)
    chart.add_element(bar)
    render :text => chart.to_s
    end
    end




    view 'main/index.html.erb':



    1
    2
    3
    4

    <script type="text/javascript" src="/javascripts/swfobject.js"></script>
    <%= @graph %>




    Generated HTML:



    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17

    <script type="text/javascript" src="/javascripts/swfobject.js"></script>

    <div id="flash_content_MS4yMTg4MzU4NTk2NDk3MDVlKzklMkZtYWluJTJGZ3JhcGhfY29kZQ=="></div>
    <script type="text/javascript">
    swfobject.embedSWF("/open-flash-chart.swf", "flash_content_MS4yMTg4MzU4NTk2NDk3MDVlKzklMkZtYWluJTJGZ3JhcGhfY29kZQ==", "600", "300", "9.0.0", "expressInstall.swf",{"data-file":"%2Fmain%2Fgraph_code"});
    </script>
    <noscript>
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="600" height="300" id="chart_MS4yMTg4MzU4NTk2NDk3MDVlKzklMkZtYWluJTJGZ3JhcGhfY29kZQ==" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="movie" value="/open-flash-chart.swf?data=%2Fmain%2Fgraph_code" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#FFFFFF" />
    <embed src="/open-flash-chart.swf?data=%2Fmain%2Fgraph_code" quality="high" bgcolor="#FFFFFF" width="600" height="300" name="chart_MS4yMTg4MzU4NTk2NDk3MDVlKzklMkZtYWluJTJGZ3JhcGhfY29kZQ==" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" id="chart_MS4yMTg4MzU4NTk2NDk3MDVlKzklMkZtYWluJTJGZ3JhcGhfY29kZQ==" />
    </object>
    </noscript>




    Accessing http://localhost:3002/main/graph_code i get what seems to be the appropiate JSON:



    1
    2
    3

    {"elements": [{"values": [1, 2, 3, 4, 5, 6, 7, 8, 9], "type": "bar_glass"}], "title": {"text": "My test"}}



  68. charlie Says:

    @Totem - The JSON is correct, so the plugin is working correctly. It seems that the swfobject.js file is causing the problem. I would test your application in Firefox if you can, FF generally gives pretty decent javascript error messages. That may help lead us to a solution.
  69. Totem Says:
    @charlie, I do not know why I didn't try FF before, but now that I tried it (FF 3.0), it works without a problem. However, IE 7 gives the error provided above.

    Any ideas on how to get it to work with IE? Unfortunately, it is a requirement for my project. Should I try using IE 8 (beta) that has some debugging features in it to try to figure this out?
  70. charlie Says:

    @Totem - well I was hoping FF would shed some light for you ... I have one more thing for you to try -

    1) Go here - http://www.macromedia.com/software/flash/about/
    -- or --
    Right click your mouse over where the flash graph should be and see what is says here "About Macromedia Flash Player X"
    2) See what version you have, if you right clicked then what is X? ...
    3) If you do not have version 9 then Install flash player 9

    So what I am assuming here, is that you have flash player 6 or at least something older than 9. Let me know.
  71. Totem Says:
    Accessing http://www.macromedia.com/software/flash/about/ gives the following
    IE has: 9,0,115,0 installed
    FF has: 9,0,124,0 installed

    I then upgraded IE, and now:
    IE has: 9,0,124,0 installed

    However, the error message is still the same in IE.
  72. charlie Says:

    @Totem - do you see graphs if you go here - http://pullmonkey.com/projects/open_flash_chart2 or do you still get the same error?
  73. Totem Says:

    That's the weird thing, I'm able to see the charts on pullmonkey on both FF and IE, but I'm only able to see the chart for my RoR app on FF. IE gives that error about invalid argument.

    IE and FF return the right JSON
  74. charlie Says:

    @Totem - see what you get when you use this swfobject - http://pullmonkey.com/projects/javascripts/swfobject.js

    That is the one I am using. Yours may have gotten corrupted or something.
  75. Totem Says:
    Same thing. FF is fine, IE gives the error.
    I'm surprised that no one else is having a similar problem.
  76. charlie Says:

    @Totem - I checked the OFC forums for you - http://sourceforge.net/forum/?group_id=201148 but nothing too helpful, however other people are having the same problem.
  77. Totem Says:

    It's kind of weird that I'm able to see the charts on the pullmonkey.com site in IE, but not my local copy. Could you zip up the swf file so that I can download it and try it out locally? Also, if you already have the RoR testing_ofc_2 project working and as you mentioned in the tutorial, could you zip it up and I can try running it locally?

    thanks for your help
  78. Totem Says:

    Hey Charlie, I've got an interesting piece of information. When I hit localhost:3000/main with FF, I get my breakpoint hit in def graph_code. However, when I try hitting it with IE (I tried reloading/refreshing, etc) def index gets hit, but NOT def graph_code.

    Not that the following log is extremely useful, but here's the log from the web server:
    IE:
    127.0.0.1 - - [18/Aug/2008:14:55:42 CDT] "GET /main HTTP/1.1" 200 1400
    - -> /main
    127.0.0.1 - - [18/Aug/2008:14:55:51 CDT] "GET /javascripts/swfobject.js HTTP/1.1" 304 0
    http://localhost:3000/main -> /javascripts/swfobject.js

    FireFox:
    127.0.0.1 - - [18/Aug/2008:14:56:21 CDT] "GET /main HTTP/1.1" 200 1400
    - -> /main
    127.0.0.1 - - [18/Aug/2008:14:56:27 CDT] "GET /javascripts/swfobject.js HTTP/1.1" 304 0
    http://localhost:3000/main -> /javascripts/swfobject.js
    127.0.0.1 - - [18/Aug/2008:14:56:27 CDT] "GET /open-flash-chart.swf HTTP/1.1" 304 0
    http://localhost:3000/main -> /open-flash-chart.swf
    127.0.0.1 - - [18/Aug/2008:14:56:27 CDT] "GET /main/graph_code HTTP/1.1" 304 0
    - -> /main/graph_code
  79. charlie Says:

    @Totem - wow that is interesting ... any browser caching going on with your site specifically? Seems that if IE does not ask for it then it has it? Try clearing your cache and go ahead and start your server on port 3001 or something other than 3000, just for a test to see what we get. Sorry if it seems like I am running out of stuff ... really haven't been able to duplicate this problem for you. I will zip this example up and send it your way tomorrow morning. If you notice that I forget, just drop me a line at charlie at pullmonkey dot com and put "open flash chart" in the subject.
  80. charlie Says:

    @Totem - the tar.gz is available here - http://pullmonkey.com/projects/open_flash_chart2/

    There is a download link after the Sample Use heading.
    http://pullmonkey.com/projects/open_flash_chart2/test_ofc_2.tar.gz

    Works for me in IE 6+, FF 2+ and Safari. Hope it works for you.
  81. derJan Says:
    I'm getting the same Stack-Error as Gallo, seems like to_json calls to_s and this is causing the infinite loop.
    I'm not using Rails, and required the gem 'json' — which one do I need?
  82. derJan Says:
    Just in case someone else has this problem: instead of the gem 'json' you need to require 'activesupport'
  83. renoo Says:
    Hello

    thx for your great work
    I noticed that the plugin works well with webrick or mongrel (script/server) but doesn't with apache through phusion 2.0.2.
    Any idea ?

    Thx again
  84. charlie Says:

    @renoo - No ideas really, what is the problem? What is the HTML that is displayed? What is the JSON that is produced? Let me know.
  85. Nanaz Says:
    Hello,

    I have a problem in relation to execution. When I run my application (with the code that is on the site), it does nothing without any error.

    I have to refresh 20 times the page on my browser and I see the chart.

    What is the problem?

    thank you

    thank you
  86. Miguel Ángel Says:
    I have tried to create custom tooltips in LineDots like in this example http://pullmonkey.com/projects/open_flash_chart/view_source_code/extra_tt .

    In the example you use "Elem.add_data_tip(value, tip)" for create each of them, but in my current project i can´t use this instruction. When i doit i receive a message from the method_mysing method.

    Note:
    I have cloned the github Version project for Open Flash Chart Plugin.

    Nice Work Man, Thanks!
    Pd: Sorry for my English
  87. Totem Says:

    @Charlie, thanks for all the help on the problem of not loading in IE. I downloaded the file you uploaded, and I noticed that you're using Rails 2.1, I'm on 2.0.2. After doing some minor changes to get it to run on 2.0.2, the same problem happened. IE 7 fails, and FF 3.0.x works fine. Maybe I just need to try it on 2.1, but I believe there's no InstantRails (yes, I'm on windows) for Rails 2.1 yet.

    On a similar note, now that I'm progressing with FF, I'm trying to update the graph depending on a drop down that the user has selected - Ajax, but I'm unable to get the 'graph_code' function called and update the
    . I believe part of the problem is that the 'id' of the
    changes everytime. Is there a sample that shows how to update the graph using AJAX?

    (I know that the this controller is getting executed for sure. Also, see that the controller is calling the "graph_code" function twice, I tried all kinds of tricks, but no avail, I don't see graph_code being executed)
    Controller code:



    1
    2
    3
    4
    5

    def selection_changed
    graph_code
    @graph = open_flash_chart_object(800,600,"/main/graph_code")
    end



    thanks
  88. Totem Says:
    BTW, where there's something missing from my previous post, I typed < div > without the spaces, but it got chewed...
  89. Totem Says:

    Please ignore my previous message about the problem with AJAX. I wrapped <%= graph %> in a specific < div > and put it in a partial and everything is fine now.

    thanks

    (Still need to figure this problem with it not working in IE 7 though...)
  90. Hhh Says:
    Am I the only one seeing no result at all?

    When i open http://localhost:3000/test_it, in the terminal, i can see

    Processing TestItController#index (for 127.0.0.1 at 2008-08-25 10:47:27) [GET]
    Session ID: BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo
    SGFzaHsABjoKQHVzZWR7AA==--c687de75d19d1a97bb4ffd54eea6a56b856016a2
    Parameters: {"action"=>"index", "controller"=>"test_it"}
    Rendering test_it/index
    Completed in 0.00224 (446 reqs/sec) | Rendering: 0.00045 (20%) | DB: 0.00000 (0%) | 200 OK [http://localhost/test_it]

    but nothing happened in my safari. Just empty.
  91. hhh Says:
    OK. i THINK I have the same question as Nanaz.

    I used the sample test_one function and all i can see from
    http://localhost:3000/test_it/test_one

    is

    {"title": {"text": "MY TITLE"}, "elements": [{"type": "bar_glass", "values": [1, 2, 3, 4, 5, 6, 7, 8, 9]}]}

    In text. is it right?
  92. HHH Says:
    This is the output from my safari/firefox 3.0.
    I can't see any flash. Can I get help?




    1
    2
    3
    4
    5
    6
    7


    <div id="flash_content"></div>
    <script type="text
    /
    javascript">
    swfobject.embedSWF(
    "
    /open-flash-chart.swf", "flash_content", "600", "300", "9.0.0", "expressInstall.swf",{"data-file":"%2Ftest_it%2Ftest_one"});
    </script>


  93. hhh Says:





    swfobject.embedSWF("/open-flash-chart.swf", "flash_content_MTIxOTY4OTkwMy42MjglMkZ0ZXN0X2l0JTJGZ3JhcGhfY29kZQ==", "600", "300", "9.0.0", "expressInstall.swf",{"data-file":"%2Ftest_it%2Fgraph_code"});

    <noscript>
    <object height="300" width="600">
    <param />
    <param />
    <param />
    <param />
    <embed src="/open-flash-chart.swf?data=%2Ftest_it%2Fgraph_code" height="300" width="600" />
    </object>
    </noscript>



    This is other output from other machine, your test_it example. Still I am not seeing anything other than a blank page

  94. Totem Says:


    This may be a silly question, but I'd like for graph_code to take parameters so that I can pass in the title, and other items that are specific to each graph that I'm rendering. If I try to change graph_code to take parameters, it barfs...

    What's the best way to do this?

    thank you
  95. charlie Says:

    @Totem - that is a good question. graph_code is an action and does not take parameters in the conventional ruby way. You will want to use the params variable and do something like this:


    1
    2
    3
    4
    5
    6
    7

    def graph_code
    title = Title.new(params[:title]) #grab it from the request parameters
    #or
    title = Title.new(@title) # grab it from an instance variable, for example, set in a before_filter.
    ...
    end

  96. charlie Says:

    @hhh - Do you have javascript enabled? Can you see my graphs? Your JSON output looks right.
  97. charlie Says:

    @Miguel Ángel - I think it is because I didn't require tooltip.rb in the init.rb of the plugin on github - get the latest version and let me know how it goes.
  98. Totem Says:

    The only problem is that I'm calling graph_code from another action. Basically, whenever the user chooses a different selection from the drop down, it calls action 'def selection_changed' with some params[], which then gathers data from the database, and then calls 'def graph_code' through the call:

    @graph = open_flash_chart_object(800,600,"/main/graph_code")

    so, I can't use params or @var from 'def selection_changed'. Currently, I'm forced to pass it through a global (dirty) or session[] (dirty too)...

    thanks
  99. Totem Says:

    @Charlie
    It looks like a Beta 1 has been released. Do we need to get the new .swf and .js or is there updates to the plugin that are needed?

    No pressure to get up to date, I know you do this on your spare time and we appreciate your hard work on this.

    Cheers!
  100. Totem Says:

    @Charlie, it looks like there's no way to setup the title style. In the 1.9.x versions I see:




    1
    2
    3
    4
    5
    6
    7
    8
    9

    def set_title(title, style='')
    @title = Graph.esc(title)
    @title_style = style if style.size > 0
    end

    def title(title, style='')
    set_title(title, style)
    end



    but in version 2, I only see:



    1
    2
    3
    4
    5
    6

    class Title < OpenFlashChart
    def initialize(text='')
    @text = text
    end
    end



    any reason for this?
    thanks!
  101. Totem Says:

    @Charlie, it looks like there's no way to setup the title style. In the 1.9.x versions I see:




    1
    2
    3
    4
    5
    6
    7
    8
    9

    def set_title(title, style='')
    @title = Graph.esc(title)
    @title_style = style if style.size > 0
    end

    def title(title, style='')
    set_title(title, style)
    end



    but in version 2, I only see:



    1
    2
    3
    4
    5
    6

    class Title < OpenFlashChart
    def initialize(text='')
    @text = text
    end
    end



    any reason for this?
    thanks!
  102. charlie Says:
    @Totem - I am using some method_missing magic, so the best thing to do when you need to figure out how to use the plugin is to look at the documentation here - http://teethgrinder.co.uk/open-flash-chart-2/title.php
    You can set the style like this:



    1
    2
    title = Title.new("SOME TITLE")
    title.set_style("{font-size: 20px; color: #A2ACBA; text-align: center;}")

    Hope that helps.
  103. Jesse Says:
    Hello, I'm having trouble figuring out hot to get the syntax highlighting to work. Here is my plugin install html output for /test_it





    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15


    <div id="flash_content_MTIyMDQ1MzA0NS41ODEyOSUyRnRlc3RfaXQlMkZncmFwaF9jb2Rl"></div>
    <script type="text/javascript">
    swfobject.embedSWF("/open-flash-chart.swf", "flash_content_MTIyMDQ1MzA0NS41ODEyOSUyRnRlc3RfaXQlMkZncmFwaF9jb2Rl", "600", "300", "9.0.0", "expressInstall.swf",{"data-file":"%2Ftest_it%2Fgraph_code"});
    </script>
    <noscript>
    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="600" height="300" id="chart_MTIyMDQ1MzA0NS41ODEyOSUyRnRlc3RfaXQlMkZncmFwaF9jb2Rl" align="middle">
    <param name="allowScriptAccess" value="sameDomain" />
    <param name="movie" value="/open-flash-chart.swf?data=%2Ftest_it%2Fgraph_code" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#FFFFFF" />
    <embed src="/open-flash-chart.swf?data=%2Ftest_it%2Fgraph_code" quality="high" bgcolor="#FFFFFF" width="600" height="300" name="chart_MTIyMDQ1MzA0NS41ODEyOSUyRnRlc3RfaXQlMkZncmFwaF9jb2Rl" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" id="chart_MTIyMDQ1MzA0NS41ODEyOSUyRnRlc3RfaXQlMkZncmFwaF9jb2Rl" />
    </object>
    </noscript>



    As you see, I figured out the highlighting at the last moment :-)

    So, I see a blank page. Do I need to have db access and pull data from it to see the graph? I was expecting a sample graph.. Thanks so much for a beautiful way to make my work fun this week :-)
  104. Jesse Says:
    Ahh! I had forgotten to copynpaste the js file and put an = (<%= javascript_... %> Works great! Very nice sample graph :-)
  105. Jesse Says:
    Hi, I'm trying to use this as in a model. I'm confused over the 'url' parameter in the open_flash_chart_object method. How can I re-write this to use in a model? I need to pass 'protein', 'carbs', 'unsaturated_fat', and 'saturated_fat' to the graph_code method. Can I do this?
  106. Jesse Says:
    I'm on the clock here. I can make a decent donation if there is a way to make the chart data static.

    Here's my situation..

    First, I have several thousand scripted pages, where it seems impossible to access the graph_code method.



    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32

    block_output[0] = <<PAGE_HEADER
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
    .
    .
    .

    <!-- common name
    #{header[:common_name]} -->
    <!-- scientific name
    #{header[:scientific_name]} -->
    <!-- manufacturer name
    #{header[:manufacturer_name]} -->

    <script type="text/javascript" src="/javascripts/clientside-trunk-515.compressed.js"></script>
    <script type="text/javascript" src="/javascripts/tabs.js"></script>
    <link href="/stylesheets/static_page.css" media="screen" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="whole_page">
    <div class="header">
    <div id="nav"></div>
    <div class="static permalink panelSet" id="content">
    <h1>
    #{food.description_long}#{header[:common_name]}</h1>
    <div id="tabBoxExample">
    <ul class="tabSet">
    #{links}
    </ul>
    <div class="panelSet">
    <div class="static charts">
    <script type="text/javascript" src="/javascripts/swfobject.js"></script>
    #{@graph}
    </div>

    PAGE_HEADER



    Here is the StaticPageController



    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27

    class StaticPageController < ApplicationController
    def index
    @graph = open_flash_chart_object(600,300,"/static_page/graph_code")
    end

    def show
    if params[:permalink]
    @page_url = StaticPage.find_by_permalink(params[:permalink])
    raise ActiveRecord::RecordNotFound, "Page not found" if @page_url.nil?
    @page = File.read("#{RAILS_ROOT}/public/static_pages/" + params[:permalink])
    @graph = open_flash_chart_object(600,300,"/static_page/graph_code")
    else
    @page = StaticPage.find(params[:id])
    end
    end

    def graph_code
    title = Title.new("MY TITLE")
    bar = BarGlass.new
    bar.set_values([1,2,3,4,5,6,7,8,9])
    chart = OpenFlashChart.new
    chart.set_title(title)
    chart.add_element(bar)
    render :text => chart.to_s
    end
    end



    I need to access this method from the scripted page (which seems to my intermediate skill impossible), or make 7500 static charts. Can you walk me through this? I have flash installed. Maybe I can make a donation and possibly contribute to the design elements. Thank you so much.
  107. charlie Says:

    @Jesse - no need for a donation. I sent you an email.
  108. Totem Says:

    I'll be interested in how this was done too. :-)
    Could you share the information?
  109. charlie Says:

    @Totem - I gave Jesse some advice and we have been working through a couple things. When he gets it all figured out, I will see if he wouldn't mind doing a guest post or a long comment here for everyone to see.
  110. Fuad Says:
    Hi,
    I used previous version of open flash chart with rails 1.2.5. Everything was working fine out there. But when I installed 2.1.0 I am getting the following error:
    NoMethodError in controller.
    undefined method `open_flash_chart_object'

    The plugin is in right place-- Vendor/plugins/open_flash_chart. I can see the method too. But rails is unable to detect that. Any clue? I would really appreciate your help because I am kind of stuck.

    Thank you.
  111. charlie Says:

    @Fuad - make sure that the init.rb file exists in RAILS_ROOT/vendor/plugins/open_flash_chart/init.rb. Also, if you haven't already, restart the application so that the plugin can load.

    The init.rb file should look like this - http://github.com/pullmonkey/open_flash_chart/tree/master/init.rb
  112. Harry Seldon Says:
    Great plugin. It worked like a charm on Rails 2.x.
    But does it work on Rails 1.2.x ?
    I got the following error on Rails 1.2.x :

    Open Flash Chart
    JSON Parse Error [Bad String]
    Error at character 1, line 1:
    -2: undefined-1: undefined0: {title: {text: "MY TITLE"}, elements: [{type: "bar_glass", values: [1, 2, 3, 4, 5, 6, 7, 8, 9]}]
  113. charlie Says:

    @Harry - There is the Rails OFC I plugin that does work with 1.2.x - http://pullmonkey.com/projects/open_flash_chart

  114. Wooram Says:
    I have same problem with totem which is about pass the parameter to graph_code
    I've tried to use static variable and global variable but failed
    And I don't know why it fails. (the variance vias became '0')
    I do like this : test_it_controller => index.erb.html => test_it_controller => view.erb.html
    In web browser : first graph with radio botton => second graph(get parameter and draw new graph)

    I set my vias static variable here
    <filter:code>
    def view
    self.setVias(params[:channel].to_i)
    puts getVias #here it print well (not zero)
    @graph2 = open_flash_chart_object(1000,700,"/test_it/graph_result")
    @columnNum2 = self.getColumn(self.parseCSV)
    end
    < /filter:code>

    And here I get it and the value of vias became '0'
    <filter:code>
    def graph_code
    vias = self.getVias
    puts vias #always change to 0
    #some other code
    end
    < /filter:code>
  115. Wooram Says:
    I have same problem with totem which is about pass the parameter to graph_code
    I've tried to use static variable and global variable but failed
    And I don't know why it fails. (the variance vias became '0')
    I do like this : test_it_controller => index.erb.html => test_it_controller => view.erb.html
    In web browser : first graph with radio botton => second graph(get parameter and draw new graph)

    I set my vias static variable here



    1
    2
    3
    4
    5
    6
    7

    def view
    self.setVias(params[:channel].to_i)
    puts getVias #here it print well (not zero)
    @graph2 = open_flash_chart_object(1000,700,"/test_it/graph_result")
    @columnNum2 = self.getColumn(self.parseCSV)
    end



    And here I get it and the value of vias became '0'



    1
    2
    3
    4
    5
    6

    def graph_code
    vias = self.getVias
    puts vias #always change to 0
    #some other code
    end

  116. charlie Says:

    @Wooram - you have graph_result and graph_code, are they supposed to be the same? Can you show me the graph_result method if it is different? You will want to pass your variables as get params like this: