chartjs / Chart.js

Simple HTML5 Charts using the <canvas> tag
https://www.chartjs.org/
MIT License
63.94k stars 11.89k forks source link

Only filtering first datasets #11665

Closed nadirbakri closed 4 months ago

nadirbakri commented 4 months ago

Expected behavior

I want the legend can filtering both of my datasets

Current behavior

Only first datasets get filtered

Reproducible sample

https://codepen.io/nadirbakri/pen/ZEPqNrE

Optional extra steps/info to reproduce

as you can see, filter only works on male not female. did i do something wrong? please enlight me

Possible solution

No response

Context

No response

chart.js version

4

Browser name and version

No response

Link to your project

No response

stockiNail commented 4 months ago

@nadirbakri because you are using 2 different datasets for doughnut.

the index at index 0 contains 2 different kind of data (male and female). To have what you are looking for you need to normalize the datasets, for instance index 0 male data, index 1 female.

See codepen:

https://codepen.io/stockinail/pen/MWxPNeQ