Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: legend navigation #11825

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

adrianbrs
Copy link

@adrianbrs adrianbrs commented Jul 1, 2024

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.

- Add legend pagination as an optional feature
- Fix multiline legend overlap in horizontal positioning
- Fix legend title left and right padding not working
- Fix legend title overlapping with multiple lines
The navigation object was being populated even with navigation disabled. Now, the navigation object is only initialized if the feature is enabled. Some improvements have also been made to code readability.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants