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

Can I have only integer values in Y - axis when actual values may be non-integer? #1047

Closed
DinooliUduwarage opened this issue Nov 4, 2019 · 6 comments

Comments

@DinooliUduwarage
Copy link

DinooliUduwarage commented Nov 4, 2019

Untitled

I want to get rid of the decimal places in the right y axis, yet my column values can be non-integer
@junedchhipa

@junedchhipa
Copy link
Contributor

Yes, you can use the yaxis.labels.formatter function to format the values according to your needs.

yaxis: [
  {
    labels: {
      formatter: function(val) {
        return val.toFixed(0);
      }
    }
  }
]

@DinooliUduwarage
Copy link
Author

DinooliUduwarage commented Nov 5, 2019

In here you can get integer values to the y axis but, if the bar graph actual value is also rounded up or down to nearest integer. When you hover over the bar you see 36 if the actual value is 35.7, and 42 when actual value is 42,3.
12
This is my actual value 35.5, but here the y axis values have decimal points,where I have limited to 2 points.
11
This is how u get values when applied above function, you can see there my actual value is rounded up n y axis have integers
what I need is to display my actual value as it is in decimal points and y axis have only integer values
@junedchhipa

@Olgagr
Copy link

Olgagr commented May 14, 2020

@DinooliUduwarage Did you solve this somehow? I would like to have the same effect.

@aeharake
Copy link

Yes, you can use the yaxis.labels.formatter function to format the values according to your needs.

yaxis: [
  {
    labels: {
      formatter: function(val) {
        return val.toFixed(0);
      }
    }
  }
]

Thank you, this works.

@invisibled
Copy link

Yes, you can use the yaxis.labels.formatter function to format the values according to your needs.

yaxis: [
  {
    labels: {
      formatter: function(val) {
        return val.toFixed(0);
      }
    }
  }
]

This is not a great solution. Any manipulation of val creates duplicate labels. eg. 1.2 and 1.6 become 1, in two spots. Would be great to have an option to force only integers.

@markalroberts
Copy link

markalroberts commented Sep 16, 2023

In here you can get integer values to the y axis but, if the bar graph actual value is also rounded up or down to nearest integer. When you hover over the bar you see 36 if the actual value is 35.7, and 42 when actual value is 42,3. 12 This is my actual value 35.5, but here the y axis values have decimal points,where I have limited to 2 points. 11 This is how u get values when applied above function, you can see there my actual value is rounded up n y axis have integers what I need is to display my actual value as it is in decimal points and y axis have only integer values @junedchhipa

Agreed - I would like to be able to have points on the chart be 2dps for accuracy but have the labels on the y-axis be rounded for readability. The label formatter seems to format both at the same time which is not good.

       yaxis: {
            labels: {
                formatter: function (val) {
                    return val.toFixed(0);
                }
            }
        },
        tooltip: {
            y: {
                formatter: function (val) {
                    return val.toString();
                }
            }
        }

Fixes it for me

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

6 participants