-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
Legend Overflow Handling #6545
Comments
You can make a custom html legend: https://www.chartjs.org/docs/latest/configuration/legend.html#html-legends |
Although we can create a custom legend, having the possibility of using the provided one and modify its height, width and overflow behaviour would be certainly easier for the user. I would like to see this feature implemented. |
The legend is drawn in the canvas (unless you add a custom html legend), they would have to add custom scrolling behaivior for this, which will never be as good as the browser's build in scrolling behaivior. This simply doesn't seem feasible? If you want scrolling behavior, using the browser's build in functionality seems like the way to go, which means using a html legend. |
You can update and move the legend position, change the font size, or even deactivate the legend dynamically by using onResize function (https://www.chartjs.org/docs/latest/configuration/responsive.html), this function passed two arguments which are Context and size. So, we can use onResize function to mutating the option configuration (the documentation for this : (https://www.chartjs.org/docs/latest/developers/updates.html) . In that documentation example shows that you can use this function to mutating the option configuration :
From here, we can utilize the query inside function updateConfigByMutating(chart) place it inside onResize method and set whatever screen size condition. |
Hi guys. If you want to customize the legend visually, please use an HTML legend. Due to Chart.js using canvas, we can't implement every requested feature cause this will bloat the code. |
I have been using Chart.js 2 quite a lot recently and there is one feature I have seen suggested but has been overlooked. Adding overflow handling for the legend would help me out immensely. Currently I have some datasets that could have anywhere from 10 - 50 keys in the legend. I have seen solutions like those found here but would like to avoid having to separate my legend from the chart. Adding the ability to set the dimensions of the legend within the canvas object as well as what do when our labels go beyond those dimensions would be very beneficial to my projects.
The text was updated successfully, but these errors were encountered: