Lets say I got this data:
Student1: {
test1: {
subject1: {
correct: 4,
questions: 10,
}
subject2: {
correct: 6,
questions: 10,
}
}
test2: {
subject1: {
correct: 10,
questions: 20,
}
subject2: {
correct: 20,
questions: 20,
}
}
}
Converting this to dataset is something like this:
label: [test1, test2]
dataset: [
{
label: subject1,
data: [4/20, 10/40],
},
{
label: subject2,
data: [6/20, 20/40],
},
options: {
scales: {
x: {
stacked: true,
},
y: {
max: 100,
stacked: true,
}
}
}
This work as charm... my problem is when I filter datasets subjects...
I need to recalculate the data..
For example when the user disable the view for dataset of subject1. I need recalculate the data to show: 60% and 100%.
How can I trigger this event and update my chart without lose information, because if the user click again to view subject1 the data has to be complete.
An image may can represent better my chart: chart