Dear fellow Web2py user,
I am trying to get a json variable into a D3 graph. This was successfull
with a simple list of dictionaries within the python/JS vairable. But nof I
want to get the famous flare data structure into my view.
In the controller I have:
def view_dendo():
import json
flare= [{ 'name': 'flare', 'children': [ { 'name': 'analytics',
'children': [ { 'name': 'cluster', 'children': [
{'name':'graph', 'size': 3938}, {'name': 'CommunityStructure',
'size': 3812}, ] }, { 'name': 'graph', 'children': [
{'name':'BetweennessCentrality', 'size': 3534}, {'name':
'LinkDistance', 'size': 5731}, {'name': 'MaxFlowMinCut', 'size':
7840}, {'name':'ShortestPaths', 'size': 5914}, {'name':
'SpanningTree', 'size': 3416} ] }, { 'name':
'CommunityStructure' } ] } ] }]
return dict(flare=XML(json.dumps(flare)))
In the View I have:
var flare = {{=flare}} ;
var nodes = cluster.nodes( flare ),
links = cluster.links(nodes);
The view doesn't matter yet because the Chrome console comes with the
message:
Uncaught SyntaxError: Unexpected token }
Comming from web2py.js
When I place the requested variable between [] : var flare = [ {{=flare}}
] ;
The message is the same but does not ref to web2py.js
Is json.dumps not supporting structured json dictionaries or am I doing
something wrong?
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.