python - Pygal - Click bar and post data? -


i trying create simple charting web app using pygal , flask chart financial data have stored in mysql database. data in db hierarchical, , want app start @ top of hierarchy , allow user drill down clicking on relevant parts of chart.

i using flask display dynamically generated pygal charts.

sample db data:

guid | name | value | parentguid | description ------------------------------------------------ 1234 | cat1 | 1     | null       | blah, blah 4567 | cat2 | 55    | null       | asfdsa 8901 | cat3 | 22    | 1234       | asfdsa 5435 | cat4 | 3     | 8901       | afdsa etc... 

i have no problem drilling down hierarchy using python + sql, i'm stumped how drill down using links in pygal chart.

@app.route('/', methods=['get', 'post']) def index():      if request.method == 'post':         chart = graph_sub(request.form['guid'])         return render_template('graph3.html', chart=chart)     else:         chart = graph_main()         return render_template('graph3.html', chart=chart)   def graph_main():      """ render svg graph """     line_chart = pygal.horizontalbar()     line_chart.title = 'root accounts'     rootaccts = getrootaccounts() # returns list of lists containing accounts , account data.     acct in rootaccts:           line_chart.add({             'title': acct[1], # acct name             'tooltip': acct[4], # acct description             'xlink': {'href': '/'} # hyperlink want pass post data form.         }, [{             'value': acct[2]), # acct value             'label': acct[4], # acct description             'xlink': {'href': '/'} # hyperlink want pass post data form.         }])     return line_chart.render()  def graph_sub(parentguid):     ### works fine if pass parent guid     ### question how pass guid pygal chart?     return line_chart.render() 

so when click on links embedded in pygal chart

'xlink': {'href': '/'} 

how can make redirect same page , pass guid of selected account post data? or there way doesn't involve post?

the page reloading every time click i'm hoping keep simple possible without having involve ajax/java/etc... though if there no other options open it.

i don't have coded yet, there additional form controls added page allow user set date ranges control how data displayed. planning use post pass user input around, before far down road, need figure out how can manage base functionality.

thoughts?


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo