http://pullmonkey.com/projects/open_flash_chart2
在rails3项目中安装OpenFlashChart的插件
rails plugin install git://github.com/pullmonkey/open_flash_chart.git
在某个controller的action中
def index @graph = open_flash_chart_object(600,300,"/controller/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
在相应的view中
<script type="text/javascript" src="/javascripts/swfobject.js"></script> <%= @graph.html_safe %>
在vender/plugin/open_flash_chart下的assert目录下的javascript中的swfobject.js,拷贝到public/javascripts/下,将assert/swf下的open-flash-chart.swf拷贝到public下