OFC2 4 Rails

outline cylinder bar 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/outline_cylinder_bar')

#in controller which is generating data for charts (for me it's charts_ofc2)
  
  def outline_cylinder_bar
    data = []
    0.upto(9) do |i|
      data << 2 + rand(9)
    end

    bar = OFC2::BarCylinderOutline.new
    bar.values= data
    bar.colour= '#D54C78'

    x_labels = OFC2::XAxisLabels.new
    x_labels.steps= 1

    x = OFC2::XAxis.new
    x.set_labels x_labels

    y = OFC2::YAxis.new(:min => 0, :max => 12, :steps => 3)

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

# display graph in view (haml)
  =@graph