-
Notifications
You must be signed in to change notification settings - Fork 464
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
Request: add setting to show all labels above stacked bar #252
Comments
I don't think this plugin should implement such a very specific (and complex) behavior that only produces your use case. It would require to introduce more and more options to accommodate all designs, which goes against what I want for this plugin API.
This approach is better, however it must be generic and work with all type of scales and elements. That means this plugin should not have to test if it's a bar chart with a linear scale which is stacked. Until there is a proper way, an alternative solution to implement your design could be to use multiple labels and only display the ones on the last bar, for example: https://codepen.io/simonbrunel/pen/GRWyLpx |
Hi,
So I'm working on this project, where I'm showing percentages of stacked bar inside the bar. But when the bar is small, the text gets clipped or is not visible. So I figured those numbers should be put outside of the bar and colored based on the dataset. Having in mind all the alignment and anchoring options that this plugin has, an option to put labels outside of stacked bar should be implemented too.
Note: setting
anchor: 'end'
only puts the top bar label outside, and the one below move to the top one.In the best case scenario it should work as follows:
The simplified version would simply add
anchor: 'outside'
setting and could leave all else for the user to set via functions.Here is an image sample:
![Screenshot 2021-06-01 195106](https://user-images.githubusercontent.com/6840479/120362532-d9c08580-c313-11eb-9c97-23d7e58891c7.jpg)
This is the way I made this:
In this code what I do is:
Issue with this code is that it sets the lower bar label on the top bar, not above both bars. So I also use pretty much same code for
offset
, to calculate the height of top bar and offset first label by that height. Its a mess and does not work perfectly (spacing is off for different height bars). But a start.P.S. ChartJS 3, Datalabels 2.0 RC
The text was updated successfully, but these errors were encountered: