OFC2 4 Rails

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

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

    data_2 = []
    x = 0
    y = 360
    while x<y
      data_2 << OFC2::ScatterValue.new(:x =>"%6.2f" % Math.sin(x/Math::RAD2DEG), :y => "%6.2f" % (Math.cos(x/Math::RAD2DEG)+0.5))
      data_2 << OFC2::ScatterValue.new(:x =>"%6.2f" % (Math.sin(x/Math::RAD2DEG)-2.3), :y => "%6.2f" % (Math.cos(x/Math::RAD2DEG)+0.5))
      data_2 << OFC2::ScatterValue.new(:x =>"%6.2f" % (Math.sin(x/Math::RAD2DEG)+2.3), :y => "%6.2f" % (Math.cos(x/Math::RAD2DEG)+0.5))
      x+=15
    end
    data_3 = []
    x = 0
    y = 360
    while x<y
      data_3 << OFC2::ScatterValue.new(:x =>"%6.2f" % (Math.sin(x/Math::RAD2DEG)+1.2), :y => "%6.2f" % (Math.cos(x/Math::RAD2DEG)-0.5))
      data_3 << OFC2::ScatterValue.new(:x =>"%6.2f" % (Math.sin(x/Math::RAD2DEG)-1.2), :y => "%6.2f" % (Math.cos(x/Math::RAD2DEG)-0.5))
      x+=15
    end


    default_dot = OFC2::SolidDot.new( :colour => '#FF0000', :dot_size => 4, :halo_size =>4 )
    circle = OFC2::Scatter.new(:colour => '#D600FF')
    circle.dot_style = default_dot
    circle.values= data_2

    default_dot = OFC2::Star.new( :colour => '#FF0000', :dot_size => 4, :halo_size =>4 )
    circle2 = OFC2::Scatter.new(:colour => '#D600FF')
    circle2.dot_style = default_dot
    circle2.values= data_3

    x = OFC2::XAxis.new(:min => -3, :max => 3)

    y = OFC2::YAxis.new(:min => -3, :max => 3)

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

    render :text => chart.render
  end
  

# display graph in view (haml)
  =@graph