Tuesday, May 23, 2017

Re: best practices for handling charts



On May 23, 2017 6:33 AM, "Alceu Rodrigues de Freitas Junior" <alceu.freitas.jr@gmail.com> wrote:
Hello to all,

I have some charts created with matplotlib and I would like to include them in my Django application.

What is the considered best practices in order to do that?

I'm considering processing the data and generating PNG files in "temporary" locations, so I when the chart file is created I just need to refer to it in the template.

This could create a problem because I would need to remove the chart file after a while, or even better, when the user logs out of the application. I did a quickly search in this group archive and couldn't find anything close related to this. It doesn't look simple to execute any kind of task when the user logs out (signals?) and there is a the risk of users just closing their browsers (which will require that I use crontab or something like it to delete old files).

Another possibility is to just open a new browser window and include in the response only the image itself.

Is there any better way to implement that?

Do you have any reason to keep the charts that are generated? You may be better off using JS to render the chart on the client side, then you don't have to worry about managing files. Maybe something like Flot charts? There's a ton of these libraries out there.


-James

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciXz8UW-xj1YhiGoJFAxxPdWzShCFMGgoWPRjmdr%3DOWPuQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment