Open Flash Chartã¨ããã°ã©ããã¼ã«ãããã¾ãããã®åã®éãããã©ãã·ã¥ã使ã£ã¦æç»ãã¾ããã°ã©ãã®è¦æ ãã¯ããªãè¯ãã§ããRailsãããç°¡åã«ä½¿ãããããªã®ã§ã試ãã¦ã¿ã¾ããã
æé ã¨ãã¦ã¯ã以ä¸ã®éãã§ã
ï¼ï¼ãã©ã°ã¤ã³ã®ã¤ã³ã¹ãã¼ã«
ï¼ï¼Controllerã¨Viewã®è¨è¿°
ï¼ï¼swfobject.jsã®ã³ãã¼
ï¼ï¼open-flash-chart.swfã®ã³ãã¼
詳ããæé ã¯ãã¡ããã
Open Flash Chart II Plugin for Ruby on Rails - Graphs(OFC2)
ï¼ï¼ã¤ã³ã¹ãã¼ã«
# ruby script/plugin install http://svn.pullmonkey.com/plugins/trunk/open_flash_chart/ + ./MIT-LICENSE + ./README + ./Rakefile + ./init.rb + ./install.rb + ./lib/open_flash_chart.rb + ./open-flash-chart.swf + ./swfobject.js + ./tasks/open_flash_chart_tasks.rake + ./test/open_flash_chart_test.rb + ./uninstall.rb
ï¼ï¼Controllerã¨Viewã®è¨è¿°
ãµã³ãã«ãåç
§ãã ããã注æããªãã¨ãããªãã®ã¯ãOFCã¨OFC2ã§ã¯ã¯ã©ã¹ã®ä¸èº«ãå
¨ç¶éããã¨ã§ããç§ãï¼ç¨®é¡ãããã¨ãç¥ããã«ãOFCãã¤ã³ã¹ãã¼ã«ãã¦OFC2ã®ãµã³ãã«ã³ã¼ãã§åããªãã¨æ©ãã§ãã¾ããã
OFC
def view @graph = open_flash_chart_object(500,250, '/projects/open_flash_chart/bar_chart', true, '/projects/') end def bar_chart bar = BarOutline.new(50, '#9933CC', '#8010A0') bar.key("Page VIEWS", 10) 10.times do |t| bar.data << rand(7) + 3 end g = Graph.new g.title("BAR CHART", "{font-size: 15px;}") g.data_sets << bar g.set_x_labels(%w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct)) g.set_x_label_style(10, '#9933CC', 0,2) g.set_x_axis_steps(2) g.set_y_max(10) g.set_y_label_steps(4) g.set_y_legend("OPENF LADF", 12, "#736AFF") render :text => g.render end
OFC2
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
ãµã³ãã«ã³ã¼ãã®graph_codeã¯è¡¨ç¤ºç¨ã®ãã¼ã¿ãçæãã¦ããã ãã§ããå®ä½ãç´æ¥è¦ãã¨ãæ°å¤çã®ç¾ åã§ããå½ç¶ãåãªããã¼ã¿ãã¡ã¤ã«ã«ç½®ãæãããã¨ãå¯è½ã§ãã
ãã®ä»ããµã³ãã«ã¯ãã¡ã
折れ線グラフ