Pie Chart from MC Aggregate


I am trying to make a pie chart students’ responses to a multiple choice question. I searched for desmos pie charts on google and found 2 here:

I cannot figure out how to modify them to take my students’ inputs though. Any ideas?

Here is the activity link:

List l is controlling the breakdown of the pie chart, so in your graph CL aggregate your student choices:

numberList("L"): aggregate(when MC1.isSelected(1) 1
                           when MC1.isSelected(2) 2
                           when MC1.isSelected(3) 3
                           when MC1.isSelected(4) 4
                           otherwise 0)

Then, I made P(x) to calculate the percentage of list L that contains a number, x. Then, make the list l = [P(1), P(2), P(3)...] with however many choices you have. Here:
Pie Chart (Fixed the issue mentioned below)

The aggregate will populate the list L with the inputs from my students, but what would I need to put in there now?

So you have L=[1,3,2,4,2,1,3,3,2,4], but those numbers will be from my students. Do I place a variable in there and make a sliders from 1-5 (there are 5 choise)?
b=1 (1<b<5)

So when running a trial, I select the first choice and it puts a 1 in the list, I select the second choice and it puts a 2 there. Now when the pie chart gets created it shows my first choice was selected 33% of the time and my second choice was selected 66% of the time, but it should be 50%-50%. Would I have to mod each slice by its given value to make it work in terms of the number of people who selected it and not the value each choice was given?

OOPS! My bad. In the function P(x) change the very last x to a 1. That should fix it.

You can just put L=[1]. The CL will overwrite it once students start making choices. The only extra you’d need is to add P(5) to the end of the list l.

It works!!! Thank you so much!