>
> Hello all, im new to python and web2py. i have been trying to get
> matplotlib working in web2py and followed the example at
> http://www.web2pyslices.com/slice/show/1357/matplotlib-howto this is
> working but i dont know how to plug my data into it.
One option is to make the following before calling plot(...) in the action
code. I assume you have already a model and data stored in the db.
a) Make a DAL set.select() of your stored data. It should look like
myrows = db(<a query>).select()
b) Map the output of the select command (a Rows class instance) to a list
of tuples and store it in a variable. For example:
mylist = list()
for row in myrows:
mylist.append((row.column_a, row.column_b))
c) Replace the hardcoded list for the dictionary element named my_plot with
the variable
return plot({'my_plot': mylist})
BTW: It's possible to reduce a, b, and c to a single command using lambda
and list comprehensions
--
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.