But analysing your code I see that you don't using the json.dumps converter 
in your data came from controller.

Try use this line , importing from gluon.contrib.simplejson:

 return gluon.contrib.simplejson.dumps( [ [r.created_on , r.qty] for r in 
rows] )
Em terça-feira, 28 de fevereiro de 2017 18:57:17 UTC-3, Oasis Agano 
escreveu:
>
> Hello im trying to add a line chart using this example but in the view i 
> see the json output instead of a graph.
> Any help?
>
> VIEW
>
> {{extend 'layout.html'}}
> <html>
> <script src="https://code.highcharts.com/stock/highstock.js";></script>
> <script src="https://code.highcharts.com/stock/modules/exporting.js";></script>
>
> <div id="chart"></div>
> <script type="application/javascript">
>  $.getJSON('http://127.0.0.1:8000/test/default/call/json/mystats', function 
> (data) {
>
>             // pie subscription
>             $('#pie_subscription').highcharts({
>
>                 series: [{
>                     type: 'line',
>                     name: '{{=T('Subscription') }} ',
>                     data:  [
>                 {{for row_pie_subscription in rows:}}
>                     ['{{=T(row_pie_subscription.created_on) }}', 
> {{=row_pie_subscription.qty}} ],
>                 {{pass}}
>                 ]
>                 }],
>
>             });
>
>         });
>  </script>
> </html>
>
>
>
> CONTROLLER
>
> @service.json
> def mystats():
>
>
>     ownstats = db(db.water_flow_log.meter == 
> auth.user.username).select(db.water_flow_log.ALL,orderby=~db.water_flow_log.date_made)
>     rows = db(db.water_flow_log.meter == 
> auth.user.username).select(db.water_flow_log.ALL,orderby=~db.water_flow_log.date_made)
>     return response.json([[r.created_on, r.qty] for r in rows])
>
>
>
> OUTPUT ON VIEW
>
> [["2017-02-24 14:32:20", 275.0], ["2017-02-24 10:52:50", 272.0], ["2017-02-24 
> 10:32:57", 270.0]]
>
>
>
> On Friday, October 7, 2016 at 8:52:18 PM UTC+2, 黄祥 wrote:
>>
>> it's work as expected, thank you so much marlysson
>> e.g.
>> import gluon.contrib.simplejson
>>
>> def test():
>>     chosen = request.args(0)
>>     query = (db.account.investor == chosen)
>>     rows = db(query).select(orderby = ~db.account.id)
>>     return gluon.contrib.simplejson.dumps([[r.product.name, 
>> r.subscription_amount] for r in rows] )
>>
>> thanks and best regards,
>> stifan
>>
>

-- 
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/d/optout.

Reply via email to