OFC2 4 Rails

lines with any dot 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/lines_with_any_dot_shape')

#in controller which is generating data for charts (for me it's charts_ofc2)
  
  def lines_with_any_dot_shape
    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 = []

    default_dot = OFC2::Dot.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12 )
    lines << OFC2::Line.new( :values => data, :dot_style => default_dot  )

    default_dot = OFC2::SolidDot.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12 )
    lines << OFC2::Line.new( :values => data.collect { |item| item + 2 }, :dot_style => default_dot  )

    default_dot = OFC2::HollowDot.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12 )
    lines << OFC2::Line.new( :values => data.collect { |item| item + 4 }, :dot_style => default_dot  )

    default_dot = OFC2::Star.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12 )
    lines << OFC2::Line.new( :values => data.collect { |item| item + 6 }, :dot_style => default_dot  )

    default_dot = OFC2::Bow.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12 )
    lines << OFC2::Line.new( :values => data.collect { |item| item + 8 }, :dot_style => default_dot  )

    default_dot = OFC2::Anchor.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12 )
    lines << OFC2::Line.new( :values => data.collect { |item| item + 10 }, :dot_style => default_dot  )

    default_dot = OFC2::Anchor.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12, :sides => 6 )
    lines << OFC2::Line.new( :values => data.collect { |item| item + 12 }, :dot_style => default_dot  )

    custom_data = []
    custom_data << OFC2::Dot.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12, :y =>  16 )
    custom_data << OFC2::SolidDot.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12, :y =>  16 )
    custom_data << OFC2::HollowDot.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12, :y =>  16 )
    custom_data << OFC2::Star.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12, :y =>  16 )
    custom_data << OFC2::Bow.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12, :y =>  16 )
    custom_data << OFC2::Anchor.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12, :y =>  16 )
    custom_data << OFC2::Anchor.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12, :sides => 6, :y =>  16 )

    lines << OFC2::Line.new( :values => custom_data)

    y = OFC2::YAxis.new(:min => 0, :max => 18, :steps => 2)

    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