OFC2 4 Rails

radar lines 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_lines')

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

    gold = OFC2::Line.new(
      :values => [3, 4, 5, 4, 3, 3, 2.5],
      :colour => '#FBB829',
      :width => 1,
      :dot_style => OFC2::HollowDot.new(:colour => '#45909F', :dot_size =>4),
      :tip => "Gold<br>#val#",
      :text => "Mr. Gold"
      #      :loop => true #important!, join last point with first, ommit here to show how it's look when loop  not set
    )

    purple = OFC2::Line.new(
      :values => [2, 2, 2, 2, 2, 2, 2],
      :colour => '#8000FF',
      :width => 1,
      :dot_style => OFC2::Star.new(:colour => '#8000FF', :dot_size =>4),
      :tip => "Purple<br>#val#",
      :text => "Mr. Purple",
      :loop => true #important!, join last point with first
    )

    labels = OFC2::RadarAxisLabels.new
    labels.colour = '#9F819F'
    labels.labels = ['Zero', '', '', 'Middle', '', 'High']

    spoke_labels = OFC2::RadarSpokeLabels.new(
      :labels => ['Strength', 'Smarts', 'Sweet<br>Tooth', 'Armour', 'Max Hit Points', 'Looks Like a Monkey'],
      :colour => '#9F819F'
    )

    x = OFC2::RadarAxis.new
    x.max = 5
    x.colour = '#DAD5E0'
    x.grid_colour = '#DAD5E0'
    x.labels = labels
    x.spoke_labels = spoke_labels

    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.tooltip = tooltip
    chart << gold
    chart << purple
    render :text => chart.render
  end
  

# display graph in view (haml)
  =@graph