T
T
turekulovass2018-06-05 13:46:46
Django
turekulovass, 2018-06-05 13:46:46

How to dynamically display charts on a page in Django using matplotlib?

Good afternoon!
Do I need to use Primary Key (pk) to build charts on matplotlib and display them independently of each other?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo101000101, 2018-06-07
@dodo101000101

Do you really need matplotlib?
If yes, then you can use matplotlib to generate png plots, and then use JS to organize an update on the page.

Here is an example of views.py to generate graphs
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

def plot_pic(request):
    # делаешь графики
    plt.draw()
    response = HttpResponse(content_type="image/jpeg")
    plt.savefig(response, format="png")
    plt.clf()
    return response

выводить с помощью чего-то такого:
In general, try plotly.js , which would make requests to the server on a timer.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question