Django chart using chart.js

29 views
Skip to first unread message

Eugene TUYIZERE

unread,
Jun 17, 2021, 5:16:23 AM6/17/21
to django...@googlegroups.com
Team,

I have a table called Indicators. This includes indicator, target and progress. Both target and progress are numbers. What I want is to display a chart target and progress for every indicator. With the code below I only get indicators I failed to display the bars (columns). Please assist

image.png

def chart(request):
dataset = Indicators.objects.values('indicator','target','progress')
indicator = list()
target = list()
progress = list()
for entry in dataset:
indicator.append(entry['indicator'])
target.append(entry['target'])
progress.append(entry['progress'])
target_series = {
'name': 'Target',
'data': target,
'color': 'blue',
}
progress_series = {
'name': 'Progress',
'data': progress,
'color': 'red'
}
chart = {
'chart': {'type': 'column'},
'title': {'text': 'Indicator Analysis'},
'xAxis': {'categories': indicator},
'series': [target_series,progress_series]
}
dump = json.dumps(chart)
--
Eugene


Eugene TUYIZERE

unread,
Jun 17, 2021, 7:04:06 AM6/17/21
to django...@googlegroups.com
please assist
--
TUYIZERE Eugene

Msc Degree in Mathematical Science

African Institute for Mathematical Sciences (AIMS Cameroon)
Crystal Garden-Lime, Cameroon


Bsc in Computer Science

UR-Nyagatare Campus

Email: eugene....@aims-cameroon.org
           eugenet...@gmail.com

Tel: (+250) 7 88 26 33 38, (+250) 7 22 26 33 38

Eugene TUYIZERE

unread,
Jun 18, 2021, 10:27:13 AM6/18/21
to django...@googlegroups.com
None to help please



-
Eugene


Lalit Suthar

unread,
Jun 18, 2021, 1:12:04 PM6/18/21
to django...@googlegroups.com
this has a good explanation https://www.youtube.com/watch?v=B4Vmm3yZPgc


--
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/CABxpZHva7h-wkjrRud_k-Oqg400k44g2mqqjCowVxYeZa7cd6g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages