OFC2 4 Rails

mix advanced many hbar chart

# include js file on site
  = javascript_include_tag 'swfobject.js'

# in controller
  #ofc2(width, height, url, id =Time.now.usec, flash_attributes = {}, flash_params = {})
  @graph = ofc2(650,300, 'charts_ofc2/mix_advanced_many_hbar')

#in controller which is generating data for charts (for me it's charts_ofc2)
  
  def mix_advanced_many_hbar

    bar = OFC2::HBar.new
    bar.values = []
    bar.values << OFC2::HBarValue.new(:left => 0, :right => 3, :tip => 'schedule: 2 actual: 3')
    bar.values << OFC2::HBarValue.new(:left => 0, :right => 3, :tip => 'schedule: 2 actual: 3')
    bar.values << OFC2::HBarValue.new(:left => 3, :right => 4, :tip => 'schedule: 3 actual: 4')
    bar.values << OFC2::HBarValue.new(:left => 4, :right => 5, :tip => 'schedule: 4 actual: 5')
    bar.colour= '#FEC13F'
    bar.text = 'actual'

    bar2 = OFC2::HBar.new
    bar2.values= [OFC2::HBarValue.new(:left => 3, :right => 4, :tip => 'schedule: 3 actual: 4')]
    bar2.colour= '#FF0000'
    bar2.text = 'schedule'

    bar3 = OFC2::HBar.new
    bar3.values= [OFC2::HBarValue.new(:left => 4, :right => 5, :tip => 'schedule: 4 actual: 5')]
    bar3.colour= '#0000FF'
    bar3.text = 'traffic'


    x = OFC2::XAxis.new
    x.min = 0
    x.max = 5

    y = OFC2::YAxis.new
    y.labels = []
    Date.today.upto(Date.today + 3) do |date|
      y.labels << date.to_s(:db)
    end

    chart = OFC2::Graph.new
    chart.title = OFC2::Title.new( :text => action_name.humanize , :style => "{font-size: 14px; color: #b50F0F; text-align: center;}")
    chart << bar3
    chart << bar2
    chart << bar
    chart.x_axis= x
    chart.y_axis= y
    render :text => chart.render
  end
  

# display graph in view (haml)
  =@graph