How to use chartjs

21 views
Skip to first unread message

Dhruvil Shah

unread,
Jan 8, 2021, 2:08:22 PM1/8/21
to django...@googlegroups.com
Basically I want to use 'chartjs' for display "Clustered Bar chart", with following things year wise

Total amount
Amount Received
Amount Left

I want to fetch data from data base and display it on chart, I have saved data of all above field  3 fields in one table for each date and I want to also fetch year from Datefield. 

So, basically can anyone give me any resource or something for such type of  requirement. Main things is how to display Clustered bar chart by fetching data from database for each year. 

David Nugent

unread,
Jan 8, 2021, 8:58:36 PM1/8/21
to django...@googlegroups.com
Some googling might get you there, but I think the chartjs documentation should get you most of the way there.

I would suggest an ajax approach - some js code on your page to retrieve the data from an API you build (a django view). You could also use DRF for this, but DRF is overkill -  you can respond with JSON or XML without it.

It might be able to render statically also, or even provide the data to a template context - depends a lot on expected environment.

Just remember that you can generate javascript in <script> tags within a html django template.
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CADsP_iwqys-XhALXm2CwGV20%2B9XXfRaD6TkASUBvE9COYzg_Qw%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages