OFC2 4 Rails

area 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/area')

#in controller which is generating data for charts (for me it's charts_ofc2)
  
  def area
    data = []
    x = 0
    y = 20
    while x<y
      data << Math.tan(x)
      x+=0.4
    end

    area = OFC2::Area.new(:values => data, :fill => '#FA00fA', :text =>'tangens', :colour => '#000000' )

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

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

    y = OFC2::YAxis.new(:min => -35, :max => 20, :steps => 5)


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

# display graph in view (haml)
  =@graph