The workflow for my Django project should go like this:
- User specifies parameters for chart generation
- Chart is generated using matplot
- Chart is then served to the user using AJAX
The possible number of charts to be generated is very large, because of differences in various parameters, so generating the charts beforehand and serving them statically is not an option.
The matplot commands show() and savfig() don’t seem to be suited to the task either.
How best can I achieve this?
Roughly like this:
Now I’m not sure how you would use AJAX to display this to the user. I think it would be easier to just insert
imgelements with appropriatesrcattributes. With jQuery, maybe like this:But if you do want AJAX, you can of course just use
$.ajax.If a chart is completely defined by the parameters passed in, and a user will likely want to see the same chart several times, consider setting liberal client caching headers to avoid re-requesting the same image from your server. This is just an optimization though.