Re: How to display a line graph in Django?

2020-07-01 Thread shedd tutt
Use chartjs

On Wed, 1 Jul 2020, 07:45 ratnadeep ray  wrote:

> 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.
>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/827e0d0c-6bbb-4511-af73-9fa379df699do%40googlegroups.com
> 
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALY6ddd%3DN_WdOY%2B4xSUx13BjVeAdEo3ywQR5F3xUZk%2B6O4Q2jA%40mail.gmail.com.


Re: How to display a line graph in Django?

2020-07-01 Thread Yamen Gamal Eldin
There's plotting library in Django.
But if I were u, I would send the data needs plotting to the template, and
plot it using a JavaScript library like chart js for small plots or d3 J's
for more professional ones.

Le mer. 1 juil. 2020 à 06:44, ratnadeep ray  a écrit :

> 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.
>
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/827e0d0c-6bbb-4511-af73-9fa379df699do%40googlegroups.com
> 
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOwHV6_cc-UbjQkSv6fRG_MbQxOWCL1goM%2BjuyBkD0vbghn2ig%40mail.gmail.com.


How to display a line graph in Django?

2020-06-30 Thread ratnadeep ray
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. 


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/827e0d0c-6bbb-4511-af73-9fa379df699do%40googlegroups.com.