never try d3.js but in highchart, i do
*controllers/default.py*
def form():
redirect_url = 'chart'
form = SQLFORM.factory(
#your_field
)
if form.process(formname = request.function).accepted:
# assign form variable
response.new_window = URL(redirect_url, args = show)
#redirect(URL(redirect_url, args = show) )
elif form.errors:
response.flash = T('Form has errors')
return dict(form = form)
def chart():
args_name = request.args(0)
query = (table.field == args_name)
rows = db(query).select()
return dict(rows = rows)
*views/default/form.html*
{{extend 'layout.html'}}
{{=form}}
*views/default/chart.html*
# your d3.js code get a rows value from either use direct python code or
web service (rest, json, etc)
e.g. in highchart for direct python code
series: [
{{
for row in rows:
}}
{
name: '{{=T(row.product.name) }} ',
data: [{{=row.amount}}, {{=row.balance}} ]
},
{{pass}}
],
e.g. if you plan to use web service (create a new controller e.g. api.py
then define the function there)
$.getJSON('{{=URL('api', 'json_column_0', args =
[request.function.replace('test_', ''), request.args(0) ] ) }}',
function(data) {
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 [email protected].
For more options, visit https://groups.google.com/d/optout.