Forum: Ruby on Rails Strange problem with Gruff not always displaying graph

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
12a8d751a8453cf1ef391bc8fa3a3a7b?d=identicon&s=25 Gimzo (Guest)
on 2006-06-05 05:48
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
8d89c3087cc6cb98793ab7c0f5658c56?d=identicon&s=25 Gimzo (Guest)
on 2006-06-08 04:50
Problem sorted, thanks
This topic is locked and can not be replied to.