Edit Web2py json output for Google Chart -
i have managed google charts plugin (http://www.web2pyslices.com/slice/show/1721/google-charts-plugin) work web2py application. using json example data (data hard coded default.py).
i struggling using own data. chart not work json data returns information as:
{"data": [["2014-03-28", 1000], ["2014-03-25", 1100]]}
when hardcode data titles, chart works:
data = [['date','sales'],["2014-03-28",1000],["2014-03-25",1100]]
this returns json as:
{"data": [["date", "sales"], ["2014-03-28", 1000], ["2014-03-25", 1100]]}
the code is:
def return_data(): data = [['date','sales'],["2014-03-28",1000],["2014-03-25",1100]] return dict(data=data)
below code using in default.py return information database, query works, it's chart doesn't!:
def return_data(): sales = db().select(db.sales.quantity, db.sales.date) data = [[row.date,row.quantity] row in sales] return dict(data=data)
somehow, think need add 'date' , 'sales' labels start of json data have not managed - think need sort of encode? - need use simplejson or can done without??
many thanks
Comments
Post a Comment