Hi, I am using the rgplot module from rubyforge to enable users to plot charts of data from my database. The plots generated are .png images and I am saving them to my application''s public/images folder. Has anyone else used rgplot? Questions I have are: is public/images the correct place to put the plots? A user can generate many many plots - is there a way to delete the images after the user logs out? Or is there a way to show the plots without saving them? Chris --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chris Finch wrote:> I am using the rgplot module from rubyforge to enable users to plot > charts of data from my database. The plots generated are .png images > and I am saving them to my application''s public/images folder. > Has anyone else used rgplot?Mm-maybe.> Questions I have are: > is public/images the correct place to put the plots?Gruff has a system to automatically blob the graphic out with the outgoing image. That might be superior. Start installing RMagick now if you want to switch. But what''s wrong with leaving the pictures in public/images? If you re-hit the same image can you avoid repainting it, and let all the caching systems take over from there?> A user can generate many many plots - is there a way to delete the > images after the user logs out?I would give each plot the same name and let nature take its course! ;-)> Or is there a way to show the plots without saving them?If you learn what Gruff::Base#to_blob does, but don''t want to switch to Gruff, you could let GnuPlot write the file, then read it, blob it, and delete it. Then it goes out your wire embedded into your HTML stream. If the site were in-house, I would just write lots of plots and then garbage-collect them at midnight every night. In terms of premature optimization, a short file that is written, read, and deleted might never actually make it to a modern hard drive, so don''t worry about the overhead of apparently writing a file! -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
thanks Phlip for the helpful comments, some replies- Regarding your suggestion of using Gruff graphs- the big problem with Gruff graphs that makes it unusable for me is that it does not support x,y plotting - that''s basic scientfic plotting of an array of x values and a corresponding array of y values. This is the reason I was forced into using rgnuplot.> But what''s wrong with leaving the pictures in public/images? If you re-hit > the same image can you avoid repainting it, and let all the caching systems > take over from there?A good idea but the chances of the same graph being required two times is very unlikely. Also, the user types query information into a form and then the graph is generated. There is no clicking on images.> I would give each plot the same name and let nature take its course! ;-)The images need to have unique names because the user usually generates many graphs from one query and observes them on one page.> If you learn what Gruff::Base#to_blob does, but don''t want to switch to > Gruff, you could let GnuPlot write the file, then read it, blob it, and > delete it. Then it goes out your wire embedded into your HTML stream.Not quite sure what you mean - but I will look into it.> If the site were in-house, I would just write lots of plots and then > garbage-collect them at midnight every night.I think this might be a satisfactory way of doing it - any tips on the method?> In terms of premature optimization, a short file that is written, read, and > deleted might never actually make it to a modern hard drive, so don''t worry > about the overhead of apparently writing a file!A quite large problem I have is that the time it takes for the file to be written is longer than the time it takes rails to display the view - I often get broken images (a red cross in place of image). When I *right-click -> show picture* the image then appears - obviously not a satisfactory situation. Does anyone have any ideas on how to prevent this? Chris.> > -- > Phlip > http://www.greencheese.us/ZeekLand <-- NOT a blog!!!--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Chris Finch wrote:> Regarding your suggestion of using Gruff graphs- > the big problem with Gruff graphs that makes it unusable for me is that > it does not support x,y plotting - that''s basic scientfic plotting of > an array of x values and a corresponding array of y values. This is the > reason I was forced into using rgnuplot.Noted: GNUplot is older and more mature. (It''s so old that its GNU doesn''t stand for GNU! I think it stands for the old Bison clone...)> > If you learn what Gruff::Base#to_blob does, but don''t want to switch to > > Gruff, you could let GnuPlot write the file, then read it, blob it, and > > delete it. Then it goes out your wire embedded into your HTML stream. > > Not quite sure what you mean - but I will look into it.It''s your best suggestion because you get to delete the file before it gets to the hard drive surface.> > If the site were in-house, I would just write lots of plots and then > > garbage-collect them at midnight every night. > > I think this might be a satisfactory way of doing it - any tips on the > method?Just point at the folder with a cron job, or the Task Manager or something. I wouldn''t know how to productize that!> A quite large problem I have is that the time it takes for the file to > be written is longer than the time it takes rails to display the view - > I often get broken images (a red cross in place of image). When I > *right-click -> show picture* the image then appears - obviously not a > satisfactory situation. Does anyone have any ideas on how to prevent > this?Is that for real? Rails must buffer and send your HTML after it waits for the file to appear. Are you spawning GNUplot in a separate process? Investigate putting timestamps on your images. my_image.png?98484838 That number is the seconds from the Epoch until the file creation time. (Get the time from the file system, and your browser and server are committed to at least refresh the file.) -- Phlip http://www.greencheese.us/ZeekLand <-- NOT a blog!!! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---