OFC2 4 Rails

mix advanced draw shape 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_draw_shape')

#in controller which is generating data for charts (for me it's charts_ofc2)
  
  def mix_advanced_draw_shape
    shape = OFC2::Shape.new(:colour => '#FF0000')
    shape.values = []
    shape.values << OFC2::ShapePoint.new(:x => 1.0, :y => -0.3)
    shape.values << OFC2::ShapePoint.new(:x => 2.0, :y => 0.0)
    shape.values << OFC2::ShapePoint.new(:x => 3.0, :y => 0.3)
    shape.values << OFC2::ShapePoint.new(:x => 4.0, :y => -0.3)
    shape.values << OFC2::ShapePoint.new(:x => 5.0, :y => 0.0)

    shape2 = OFC2::Shape.new(:colour => '#00FF00')
    shape2.values = []
    shape2.values << OFC2::ShapePoint.new(:x => 0.0, :y => 0.4)
    shape2.values << OFC2::ShapePoint.new(:x => 0.0, :y => -0.4)
    shape2.values << OFC2::ShapePoint.new(:x => 2.0, :y => -0.4)
    shape2.values << OFC2::ShapePoint.new(:x => 2.0, :y => 0.4)

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

    y = OFC2::YAxis.new
    y.set_offset true
    y.labels = ["y_label"]

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

# display graph in view (haml)
  =@graph