Sample Use
Download the sample OFC2 project.- rails testing_ofc_2
- cd testing_ofc_2
- script/plugin install git://github.com/pullmonkey/open_flash_chart.git
- If the above line did not work for you, you can also use http -
script/plugin install http://github.com/pullmonkey/open_flash_chart.git - script/generate controller test_it
- 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
- 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 %>
- Copy swfobject.js from the plugin's assets/ directory (will make this happen at install time later) to your RAILS_ROOT/public/javascripts directory
- Copy open-flash-chart.swf from the plugin's assets/ director to your RAILS_ROOT/public/ directory
- script/server
- Browse to http://localhost:3000/test_it
- Let me know how it goes, thanks.
Sample Graphs
View Source Code
View Source Code
View Source Code
View Source Code
View Source Code
View Source Code
View Source Code
View Source Code
View Source Code
View Source Code