OFC2 4 Rails

radar minimal view 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/radar_minimal_view')

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

    spokes = []
    'a'.upto('p') do |letter|
      spokes << letter
    end
    values = []
    [30,50,60,70,80,90,100,115,130,115,100,90,80,70,60,50].each_with_index do |number, index|
      values << OFC2::SolidDot.new(:colour => '#D41E47', :tip => "#val#<br>Spoke: #{spokes[index]}", :value => number)
    end

    line = OFC2::Line.new(
      :values => values,
      :colour => '#FBB829',
      :width => 2,
      :text => "Hearts",
      :font_size => 10,
      :loop => true #important!, join last point with first
    )

    x = OFC2::RadarAxis.new
    x.max = 150
    x.steps = 10
    x.colour = '#DAD5E0'
    x.grid_colour = '#EFEFEF'

    tooltip = OFC2::Tooltip.new(:mouse => 1)

    chart = OFC2::Graph.new
    chart.title = OFC2::Title.new( :text => action_name.humanize , :style => "{font-size: 14px; color: #b50F0F; text-align: center;}")
    chart.radar_axis= x
    chart.bg_colour = '#ffffff'
    chart.tooltip = tooltip

    chart << line
    render :text => chart.render
  end
  

# display graph in view (haml)
  =@graph