OFC2 4 Rails

inline line chart

# include js file on site
<%= javascript_include_tag 'swfobject.js' %>

# when you use ofc2_inline method you don't neeed extra controller which serving data

# lets say you have a controller Charts
class ChartsController < ApplicationController
  # and action inline_line
  def inline_line
    title = OFC2::Title.new(
      :text => action_name.humanize ,
      :style => "{font-size: 14px; color: #b50F0F; text-align: center;}"
    line_dot = OFC2::Line.new
    line_dot.values= [9,8,7,6,5,4,3,2,1]
    line_dot.colour = '#FFAAFF'

    line_dot_2 = OFC2::Line.new
    line_dot_2.values= [9,8,7,6,5,4,3,2,1].reverse

    chart = OFC2::Graph.new
    chart.title= title

    chart << line_dot
    chart << line_dot_2

    @graph = ofc2_inline(650,300,chart,'inline_line')
# notice that instead url (like was in another examples) we set an chart object
# @graph = ofc2_inline(650,300,chart,'inline_line')
# the 4th parameter is id, if you not set it, it will be automaticaly generated
# every inline chart generated on the same page must have unique id!

# ok, we have controller and action, now display graph in a view for that action
# for this tiny example it is app/views/charts/inline_line.html.erb