-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Bar chart labels #1031
Bar chart labels #1031
Conversation
//_chart.label() sets _renderLabel to true. | ||
//Set back to false to disable renderLabel by default | ||
_chart.renderLabel(false); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like an odd default value, the Y coordinate? why not just leave .label()
uninitialized?
I must be missing something about the label = Y coordinate default. Other than that this looks really good. Thanks for including tests and for making it backward-compatible; since it is, we can include it in 2.0. |
I figured that most users want bar labels to display the y-axis value. For my use case in particular, I had some bars that were order of magnitudes taller than others (150 vs 3). Since the small bars are so tiny, 2 or 3 pixels, I wanted a way to convey that they were not zero. |
Oh, I get it now. Yes, of course that's a reasonable default. I guess we'll probably have to default in some floating point formatter. Your comment about tiny bars also reminds me that it would be nice to make the labels clickable. You can take on these improvements if you want; otherwise I'll just address them when I merge. I also see that I'll need to do something about the padding; the stacked bar example makes it painfully obvious how poorly |
I can take a look at making the labels clickable - that should be straight forward. How many decimal places should the default label generator format floating points to? Maybe 2? What do you have in mind for y axis padding? |
Thanks @nreese! We can use the same default floating point formatting that we use for the filters. It's https://github.com/dc-js/dc.js/blob/develop/src/utils.js |
It might be enough just to have padding on each side instead of duplicated on X and Y. But I don't want to commit to a design yet, because there is too much in dc.js which was designed hastily and continues to haunt us. |
I have made the labels clickable and used dc.utils.printSingleValue for format the label value. Let me know if anything else is needed. |
It looks like there is a merge conflict. How do I look at/fix the merge conflict? Are you waiting on action from me for this pull request? |
Thanks @nreese, don't worry about the merge conflict, although in the future it is a best practice not to check in the build artifacts when doing a PR. (It usually doesn't matter but it makes life difficult for the maintainer in rare cases, so that's why we put that in the contribution guidelines.) Sorry for the slow turnaround. I haven't had time to thoroughly review this. But it looks ready afaict. |
This merged to 2.0 beta 21. Thanks! @nreese, please let me know how to credit you in the AUTHORS file - your commits are marked with Reese and a bogus email address. (Probably a good idea to set your name and your email in git if you're contributing to projects on GitHub.) |
pull request for issue #211 adding support for bar chart labels