I have a partial that I am rendering that contains several graphs generated by gruff. These graphs are displaying data points pulled from my database, and I want to allow the user to change the datapoints (filter based on criteria). I have the graphs being written into a directory and I have the filter actions set up to redraw the graphs which is getting done (if I look at the directory the graphs are put into the files are being replaced with the new graphs) but the browser is not redrawing the partial after I update the graphs. I am calling the graphs via an image tag. The filter is being set by a form_remote_tag. My question really is how do I force a partial to redraw everything no matter what. Andrew
generating a new, unique graph file name everytime the data is changed should do it. Andrew Filipowski wrote:> I have a partial that I am rendering that contains several graphs > generated by gruff. These graphs are displaying data points pulled from > my database, and I want to allow the user to change the datapoints > (filter based on criteria). I have the graphs being written into a > directory and I have the filter actions set up to redraw the graphs > which is getting done (if I look at the directory the graphs are put > into the files are being replaced with the new graphs) but the browser > is not redrawing the partial after I update the graphs. I am calling > the graphs via an image tag. The filter is being set by a > form_remote_tag. My question really is how do I force a partial to > redraw everything no matter what. > > Andrew
Lou Vanek <vanek@...> writes:> > generating a new, unique graph file name everytime the data is changed shoulddo it.> > Andrew Filipowski wrote: > > > I have a partial that I am rendering that contains several graphs > > generated by gruff. These graphs are displaying data points pulled from > > my database, and I want to allow the user to change the datapoints > > (filter based on criteria). I have the graphs being written into a > > directory and I have the filter actions set up to redraw the graphs > > which is getting done (if I look at the directory the graphs are put > > into the files are being replaced with the new graphs) but the browser > > is not redrawing the partial after I update the graphs. I am calling > > the graphs via an image tag. The filter is being set by a > > form_remote_tag. My question really is how do I force a partial to > > redraw everything no matter what. > > > > AndrewAnother option is to send the graph data to the browser directly rather than writing it to disk. Not the most efficient practice but not necessarily bad if your data source changes constantly. def make_graph g = Gruff::Line.new ... send_data(g.to_blob, :filename => "ck.png", :type => ''image/png'', :disposition => ''inline'') end Then you can just invoke the controller method directly in your image source: <img src="/controller/make_graph" />
On Dec 5, 2005, at 9:56 PM, Tyler Kovacs wrote:> > > Another option is to send the graph data to the browser directly > rather than > writing it to disk. Not the most efficient practice but not > necessarily bad if > your data source changes constantly. > > def make_graph > g = Gruff::Line.new > ... > send_data(g.to_blob, :filename => "ck.png", :type => ''image/ > png'', :disposition > => ''inline'') > end > > Then you can just invoke the controller method directly in your > image source: > > <img src="/controller/make_graph" />hm, I tried this before I asked the question but perhaps I did something wrong. I am writing multiple graphs to the page and kept getting a multiple render error which made me go the route of writing the graphs to disk. Andrew> > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails
there''s also the ''no-cache'' header directive, http://www.htmlgoodies.com/beyond/reference/article.php/3472881 Andrew Filipowski wrote:> I have a partial that I am rendering that contains several graphs > generated by gruff. These graphs are displaying data points pulled from > my database, and I want to allow the user to change the datapoints > (filter based on criteria). I have the graphs being written into a > directory and I have the filter actions set up to redraw the graphs > which is getting done (if I look at the directory the graphs are put > into the files are being replaced with the new graphs) but the browser > is not redrawing the partial after I update the graphs. I am calling > the graphs via an image tag. The filter is being set by a > form_remote_tag. My question really is how do I force a partial to > redraw everything no matter what. > > Andrew
Sorry to bump such an old topic, but I''ve run in to much the same problem. I''m rendering a partial which is re-rendered every so often using AJAX. Both suggestions mentioned above don''t appear to work (changing the filename sent with each request and calling the controller directly). I''ve also used a simple method to alter HTTP headers with pragma and no-cache, all to no avail. Does anyone have any other suggestions? For reference, here''s some snippets: Gruff controller: send_data(g.to_blob, :disposition => ''inline'', :type => ''image/png'') View: <img src="<%= url_for(:controller => ''graphs'', :action => ''show'') %>" /> -- 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 -~----------~----~----~----~------~----~------~--~---