OFC2 4 Rails

mix advanced tooltip 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/mix_advanced_tooltip')

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

    default_dot = OFC2::Dot.new( :colour => '#FF0000', :dot_size => 10, :halo_size =>12 )
    line_dot = OFC2::Line.new
    line_dot.dot_style = default_dot
    line_dot.set_tip('#val#<br>Your text here for line')
    line_dot.text= 'actual sales'
    line_dot.font_size= '12'
    line_dot.colour= '#FF0000'
    line_dot.dot_size= 5

    bar = OFC2::Bar.new
    bar.tip = '#val#<br>Your text here for bar'
    bar.text= 'forecast sales'
    bar.font_size= '12'
    bar.colour= '#00FF00'

    line_values= []
    bar_values= []
    max = 12

    0.upto(max) do |i|
      actual_sales = rand(max)
      forecast_sales = rand(max)

      _tooltip = "Summer Sales Blitz<br>actual sales: #{actual_sales}<br>forecast sales:#{forecast_sales}"

      line_values << OFC2::Dot.new(:value => actual_sales, :colour => '#FF0000', :tip => _tooltip)
      bar_values << OFC2::BarValue.new(:top => forecast_sales, :colour => '#00FF00', :tip =>_tooltip)
    end

    line_dot.values= line_values
    bar.values= bar_values

    chart = OFC2::Graph.new
    chart.title= title
    chart << line_dot
    chart << bar

    tooltip = OFC2::Tooltip.new
    tooltip.hover
    tooltip.stroke=5
    tooltip.shadow=true
    tooltip.colour="#e2ff60"
    tooltip.background_colour="#FFFFFF"
    tooltip.title="{font-size: 14px; font-weight: bold; color: #000000;}"
    tooltip.body="{font-size: 10px; font-weight: bold; color: #707070;}"

    chart.tooltip = tooltip

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

    chart.y_axis= y

    chart.bg_colour= '#FFFFFF'

    render :text => chart.render
  end
  

# display graph in view (haml)
  =@graph