Hi all,
I have wrote a python program to display the line graph as follows:
import matplotlib.pyplot as plt
x = [1,2,3]
y = [2,4,1]
plt.plot(x, y)
plt.xlabel('x - axis')
plt.ylabel('y - axis')
plt.title('My first graph!')
plt.show()
Now I need to display the same via Django. So I think I need to write the above code in the view and then redirect the same to the html template file. Am I right?
In that case, how to send the request objects related to the line chart to the template?
Normally, we send in the following format:
def view1(request)
return render(request, 'display_report.html', { 'var1': "abc", ...
... })
So if we are trying to display the line graph generated by the above code, how to do so ?
Please share your inputs.
Thanks.