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下
本文介绍如何在Rails3项目中安装并使用OpenFlashChart插件,通过示例展示了如何创建图表并在控制器中生成图表代码,同时给出了必要的文件复制路径。
112

被折叠的 条评论
为什么被折叠?



