Thanks for answering James, I commented your e-mail below:


Em 23/05/2017 12:06, James Schneider escreveu:


On May 23, 2017 6:33 AM, "Alceu Rodrigues de Freitas Junior" <[email protected] <mailto:[email protected]>> 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.

http://www.flotcharts.org/flot/examples/


Well, besides having to learn a new API and not reusing the read-to-use code from matplotlib? :-) Just kidding, it makes sense to use client-side for that and avoiding the temporary files problem completely but I really would like to reuse what is already implemented, unless it gives more trouble than using something like Flot.

--
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 [email protected].
To post to this group, send email to [email protected].
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/c95a5ccb-37c6-53ee-26a3-9296265ee371%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to