[web2py] Re: Google charts plugin added
All you need to do is return data as an array. That's all the controller does. So you need to learn how to retrieve data using the DAL, and put it into an array. For example, you can get rows from a query, and iterate over the returned rows, building up the array. On Wednesday, November 13, 2013 9:42:39 PM UTC+11, Sarbjit wrote: > > Thanks Tim, > > I have a question: > > In your example, data is present in controller itself, how can I store the > data effectively in database and then use that data for plotting graphs? > > Can you please provide an example of how this can be stored/retrieved from > db? I searched the net and found people suggesting pickle/json for > storing/retrieving from db, but I'm not having any experience with both. > Can you please help. > > def plugin_return_data(): > data = > [['Year','Sales','Expenses'],["2004",1000,400],["2005",1100,440],["2006",1200,600], > ["2007",1500,800],["2008",1600,850],["2009",1800,900]] > return dict(data=data) > > -Sarbjit > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Google charts plugin added
Thanks Tim, I have a question: In your example, data is present in controller itself, how can I store the data effectively in database and then use that data for plotting graphs? Can you please provide an example of how this can be stored/retrieved from db? I searched the net and found people suggesting pickle/json for storing/retrieving from db, but I'm not having any experience with both. Can you please help. def plugin_return_data(): data = [['Year','Sales','Expenses'],["2004",1000,400],["2005",1100,440],["2006",1200,600], ["2007",1500,800],["2008",1600,850],["2009",1800,900]] return dict(data=data) -Sarbjit -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
[web2py] Re: Google charts plugin added
On Thursday, October 3, 2013 4:03:09 PM UTC-7, Tim Richardson wrote: > > I added a google charts plugin > http://www.web2pyslices.com/slice/show/1721/google-charts-plugin > Thanks! /dps -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.