Strange problem with Gruff not always displaying graph


#1

Hello,

I am having a strange problem with Gruff not always displaying the graph
on the page. On some pages, the graph is displayed fine. On others,
however, I just get the number relating to the id of the requested item

  • in my case, report.

Does anyone know how to solve this problem?

I have the following in my controller:

def create_graph

 g = Gruff::Line.new(290)
 g.title = "Reports"

 g.theme = {
   :colors => ['#CC0000', '#00CC00', '#cc6633', '#cc9966',

#99cc99’],
:marker_color => ‘black’,
:background_colors => [’#FAFAFA’, ‘#FAFAFA’]
}

  report_number = []
  labels = []

 @report = User.find(session[:user]).reports.find(params[:id])
 @records = @report.report_items.find(:all, :conditions => [

“report_context = ‘Required’” ] )

  for report_items in @records
    report_number << report_item.amount.to_i
labels << report_item.date
  end

  g.data("Reports", report_number)
  g.labels = labels

  send_data(g.to_blob,
:disposition => 'inline',
:type => 'image/png',
:filename => "report_img.png")

end

Then, in the view, I have the following:

<%= image_tag url_for(:controller => ‘reports’, :action =>
‘create_graph’, :id => @report) %>

Why would the image appear for some of the report pages and not the
others?

Any help on this would be great.

Thanks


#2

Problem sorted, thanks