Hello again, Is anyone else using matplotlib to generate dynamic plots for use with web2py. Any pointers on a better way to do it that will allow dynamic refreshing? Thanks for any help, G
On Nov 14, 3:42 pm, G <[email protected]> wrote: > Hello, > I am using web2py to monitor and control an instrument. I am > dynamically generating plots using matplotlib following the DNA > application example from SC2009 (http://www.web2py.com/examples/static/ > sc/sc_dna_talk.pdf) > > I was able to get the basic aspects working based on that example. > However, I want to automatically display new plots as new data is > available. I am using the following code in the view: > > <script> > var auto_refresh = setInterval( > function() > { > $('#loaddiv').load('statusbox.load'); > $('#threshpng').html('<img src="/myapp/default/dataThreshPlot.png">');}, > 5000); > > </script> > <div id="loaddiv">loading...</div> > <div id="threshpng">png loading</div> > > The statusbox.load generates a table with some statistics about the > data, and this successfully updates every 5 seconds as desired. > However, the dataThreshPlot never gets refreshed, only the initial > version is displayed. (a timestamp is written to the plot when it is > generated so I can verify this fact). > > If I simply browse to localhost:8000/myapp/default/dataThreshPlot.png > the plot is properly generated and displayed each time I refresh the > page. > > I have tried adding this code to the dataThreshPlot function in the > controller: > > response.headers['Expires'] = time.strftime("%a, %d %b %Y %H:%M:%S > +0000", time.gmtime(time.time()+1)) > > to try to avoid caching, but still no luck. > > I also tried making a very simple controller function as follows: > > def dataThreshPage(): > return dict(threshim= URL(r=request,f=dataThreshPlot)) > > and view: > <img src={{=threshim}}> > > and tested that localhost:8000/myapp/default/dataThreshPage presents > the plot as expected. > > I then modified the jquery refresh code to: > > <script> > var auto_refresh = setInterval( > function() > { > $('#loaddiv').load('statusbox.load'); > $('#threshpng').load('/myapp/default/dataThreshPage');}, 5000); > > </script> > <div id="loaddiv">loading...</div> > <div id="threshpng">png loading</div> > > but still no luck. > > Any suggestions for how to get these plots to refresh? > Thank you, > G

