How to display multiple pie charts based on multiple lists?

23 views
Skip to first unread message

ratnadeep ray

unread,
May 13, 2020, 12:48:00 AM5/13/20
to Django users
Hi all, 

I have a requirement where I need to display multiple pie charts based on multiple lists. 

Currently, I am able to display one pie chart involving 2 lists. Below is the views.py code for the same: 

# Create your views here.
from django.shortcuts import render

def pie_chart(request):
    labels = ["A", "B", "C"]
    data = ["10", "15", "2"]

   return render(request, 'pie_chart.html', {
        'labels': labels,
        'data': data,
    })


Now what if we have another pair of lists as follows: 
    labels1 = ["X", "Y", "Z"]
    data1 = ["10", "15", "2"]

So can anyone say what changes should I made in the above code  to display 2 pie charts displaying labels/data and labels1/data1 ? 

Thanks in advance. 

Reply all
Reply to author
Forward
0 new messages