OFC2 4 Rails

lines with any line style 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/lines_with_any_line_style')

#in controller which is generating data for charts (for me it's charts_ofc2)
  
  def lines_with_any_line_style
    title = OFC2::Title.new( :text => action_name.humanize , :style => "{font-size: 14px; color: #b50F0F; text-align: center;}")

    data = [2,2,2,2,2,2,2,2,2]

    lines = []

    line_style = OFC2::LineStyle.new(:on => 30, :off => 10)
    lines << OFC2::Line.new( :values => data, :line_style => line_style, :colour => '#D4C345', :width => 2  )

    line_style = OFC2::LineStyle.new(:on => 30, :off => 30)
    lines << OFC2::Line.new( :values => data.collect { |item| item + 2 }, :line_style => line_style, :colour =>'#C95653', :width => 1  )

    line_style = OFC2::LineStyle.new(:on => 10, :off => 30)
    lines << OFC2::Line.new( :values => data.collect { |item| item + 4 }, :line_style => line_style, :colour => '#8084FF', :width => 6  )

    y = OFC2::YAxis.new(:min => 0, :max => 8, :steps => 4)

    chart = OFC2::Graph.new
    chart.title= title
    lines.each do |line|
      chart << line
    end
    chart.y_axis= y

    render :text => chart.render
  end
  

# display graph in view (haml)
  =@graph