chartjs / Chart.js

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

feature: legend navigation #11825

Open adrianbrs opened 6 days ago

adrianbrs commented 6 days ago

I needed this feature to manage many legends on the same chart, but I couldn't find anything besides the HTML legends. Therefore, I decided to implement this feature, and I hope it can be useful for the Chart.js core, as I believe it is essential.

An example of the navigation working, and also the documentation created, can be found here: https://cerbaro.dev/Chart.js/samples/legend/navigation.html

image

Furthermore, during the process I encountered some issues and ended up solving them.

11280 - Horizontal padding of the legend title does not work

11824 - Horizontal legend multiline labels overlaps

I am willing to collaborate with any changes you deem necessary.

Issues related to legend pagination: #10893, #7100, #6545, #3761, #5561, #11425 (There's probably others as well).

There is an open issue for a refactor in the legend plugin (#9342), but I don't know when version 5 will be released, perhaps it would be interesting to add this navigation to the current version anyway.

I would be happy to contribute to the new version if needed.