Login

Snippets by banderkat

Snippet List

model queries to Google Visualization DataTables

Helper functions to use the Google Visualization API in Django. Module stores queries to use and creates a JSon representation of a Google Visualization DataTable for each by inspecting the query's model. Looks up any choices defined for the columns. Depends on Google Visualization Python API: https://code.google.com/p/google-visualization-python/ To use, define the queries to use with the Visualization API at the head of views.py with: add_query(queryset, 'query name') then in view functions, get the JSon representation of a Google Visualization DataTable for the query with: my_json = get_viz_json('query name') Within the HTML template, pipe the JSon through safe: var dataTable = new google.visualization.DataTable( {{ my_json|safe }} );

  • Google Visualization
  • charts
Read More

banderkat has posted 1 snippet.