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

BarLabels for Column Charts #7

Closed
akshayakrsh opened this issue Apr 28, 2014 · 3 comments
Closed

BarLabels for Column Charts #7

akshayakrsh opened this issue Apr 28, 2014 · 3 comments

Comments

@akshayakrsh
Copy link

Is there a way to change the figure displayed on the bars of a column chart? E.g. if my data object looks like:

var dataObj = [
{ x : '2010', y : 5 },
{ x : '2011', y : 15 },
{ x : '2012', y : 20 },
{ x : '2013', y : 0 },
{ x : '2014', y : 0 },
];

Then instead of showing "0" for x = 2013/2014 I want to show "-" on top. Possible?

@heavysixer
Copy link
Owner

Yes it is, all you want to do is something like this:

chart
.using('barLabels', function(label) {
    label
    .text(function(d) {
        if(+d[this.valueKey] < 1){
            return '-';
        }else{
            return d[this.valueKey];
        }
      });
  });

@akshayakrsh
Copy link
Author

Yup, works like charm! Probably should add it in the documentation somewhere.

@heavysixer
Copy link
Owner

Yes, I think I'll need to stop adding features soon so that I can catch up on documentation :-(

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

No branches or pull requests

2 participants