Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8129629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:22:48+00:00 2026-06-06T08:22:48+00:00

The workflow for my Django project should go like this: User specifies parameters for

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:22:50+00:00Added an answer on June 6, 2026 at 8:22 am

    Roughly like this:

    import django.http
    import matplotlib.pyplot
    
    # This is your view function, hook it up to your URLconf.
    def chart(request, *args):
        # ...extract chart parameters from request.GET and/or args...
        fig = matplotlib.pyplot.figure(...)
        # ...draw your chart, invoking methods on fig...
        response = django.http.HttpResponse(content_type='image/png')
        fig.savefig(response, format='png')
        return response
    

    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 img elements with appropriate src attributes. With jQuery, maybe like this:

    var src = '/chart/?' + $.param({
            // This all ends up in request.GET
            type: 'something',
            foo: 'bar',
            myParam: 123
        });
    $('#displayArea').empty().append($('<img>').attr('src', src));
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to build an API service using Django. A basic workflow goes like
The workflow I am dealing with (user-wise) looks like this: User submits information and
I want to implement user registration using captcha in Django. The workflow of django-registration
The workflow requested by customer is something like this : The user on registration
The basic workflow of my Drupal site is this: User submits article via the
I'd like to love Django, but this business of static and media files in
Im looking to optimize our translation workflow for a django/python based project. Currently we
The workflow is like this: we download a template form, prefill values which will
My usual workflow when working with git, is something like this: create a local
The workflow is like this: I receive a scan of a coupon with data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.