I would like to do some graphics in my django application. I'm using Flot. I am a newbee with regard to javascript and I do not know how to pass parameters in my situation. This is my code:
view.py
data = []
query = tab_data.objects.all()
for row in query:
data.append([str(row.time), str(row.rate)])
data = json.dumps(data, cls=DjangoJSONEncoder)
...
return render_to_response('index.html', {'data' : data}, context_instance=RequestContext(request))
index.html
<div class="portlet-body">
<div id="site_statistics_loading">
<img src="/static/assets/img/loading.gif" alt="loading" />
</div>
<div id="site_statistics_content" class="hide">
<div id="site_statistics" class="chart"></div>
</div>
</div>
...
... # at the end of the page I have this
Index.initCharts(); // init index page's custom scripts
Index.js
initCharts: function () {
if (!jQuery.plot) {
return;
}
var data = []; # Here I would like my data.
How do I pass the data to file index.js? Sorry for the trivial question but I do not know how to do ... thanks