Hi Folks, since I have scruffy up and running now I´d like to integrate the desired images on some of my rails views. But neither scruffy nor rails docs say something about this and I cannot find examples or help on this. So I hope somebody on this forum has experiences in integrating scruffy images on rails views. I find out how to go the easy and obvious way: Export image to a file and then bind the exported file on the view template. But I wonder if I cannot get scruffy images directly on my rails pages without exporting it to disk first. My approach with a simple example from Brastens page: I created this method in my views helper class: def generate_img() graph = Scruffy::Graph.new graph.title = "Comparative Agent Performance" graph.value_formatter = Scruffy::Formatters::Percentage.new(:precision => 0) graph.add :stacked do |stacked| stacked.add :bar, ''Jack'', [30, 60, 49, 29, 100, 120] stacked.add :bar, ''Jill'', [120, 240, 0, 100, 140, 20] stacked.add :bar, ''Hill'', [10, 10, 90, 20, 40, 10] end graph.point_markers = [''Jan'', ''Feb'', ''Mar'', ''Apr'', ''May'', ''Jun''] graph.render(:width => 800, :as => ''JPG'') end And in my views rhtml page I put this: <%= generate_img %> Unfortunately it display rubbish instead of the expected image. The encapsulation with the <img> tag is also not working. Can anyone point me to the right direction? Thanks & Regards, Christian -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Doh! Mixed up the name in the headline: Must be "Scruffy" not "Scruff". Sorry! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Okay I figured it out myself, should have had a closer look on this forum before ;-) Here we go: In my controller I added this method: def show_img graph = Scruffy::Graph.new graph.title = "Comparative Agent Performance" graph.value_formatter = Scruffy::Formatters::Percentage.new(:precision => 0) graph.add :stacked do |stacked| stacked.add :bar, ''Jack'', [30, 60, 49, 29, 100, 120] stacked.add :bar, ''Jill'', [120, 240, 0, 100, 140, 20] stacked.add :bar, ''Hill'', [10, 10, 90, 20, 40, 10] end graph.point_markers = [''Jan'', ''Feb'', ''Mar'', ''Apr'', ''May'', ''Jun''] send_data(graph.render(:width => 800, :as => ''PNG''), :type => ''image/png'', :disposition=> ''inline'') end And in the views rhtml file I added this: <img src="<%= url_for(:action => ''show_img'') %>"/> And now it works! Regards, Chris -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---