-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Rounding error on Y-axis when all Y values are zeroes #1123
Comments
have you tried |
What is that? Can't see it here: https://jitpack.io/com/github/PhilJay/MPAndroidChart/v2.2.5/javadoc/ |
it's in iOS portion, I am not sure if you can see it on android side |
What class is this method in and what does it do? |
should be similar to #315 |
Sorry, which of my two problems is this supposed to help? Trailing zeroes or rounding error? |
oops, I thought you are having duplicated zeroes. Are you asking about the number formatter?You can take a look at maximumFractionDigits and minimumFractionDigits |
I think I explained my problem in the first post. |
as I said, maximumFractionDigits and minimumFractionDigits seems solution to me |
Enlighten me - what values do I need to assign to maximumFractionDigits and minimumFractionDigits? |
hmm, if you only want max two, like 0.11, it will avoid situation like 0.111111111111. |
Regret it does not Test code
|
OK first of all, if you see something contains |
Changed to
No effect. Same thing as on the picture from the previous post |
that's simply not true: I used ChartsDemo and you can see it has 23, 23.16, and 23.2 on the chart. ChartYAxis *leftAxis = _chartView.leftAxis;
leftAxis.labelFont = [UIFont systemFontOfSize:10.f];
leftAxis.labelCount = 8;
leftAxis.valueFormatter = [[NSNumberFormatter alloc] init];
leftAxis.valueFormatter.maximumFractionDigits = 2;
leftAxis.valueFormatter.minimumFractionDigits = 0;
leftAxis.valueFormatter.negativeSuffix = @" $";
leftAxis.valueFormatter.positiveSuffix = @" $";
leftAxis.labelPosition = YAxisLabelPositionOutsideChart;
leftAxis.spaceTop = 0.15;
leftAxis.axisMinValue = 0.0; // this replaces startAtZero = YES |
What is not true? My data are integer numbers and I don't want decimals after dot on the Y axis |
look I think it's all about the value formatter you are using... The library will take all values into double type, so even you mean integer, it's still double. If you don't want decimals, simply set maximumFractionDigits = 0. you need to take a look at the number formatter documentation, it's all there. |
I need to show values as float if they're float and as integer if they are integer - the data comes from web and I don't know that beforehand |
How can I set integers for values label in Horizontal Bar chart? |
I can't get the Y-axis labels right using the latest version of the library
![simulator screen shot jun 10 2016 7 08 13 pm](https://cloud.githubusercontent.com/assets/1481807/15970723/bd83d412-2f3e-11e6-809c-a54ae398229d.png)
By default they include trailing zeroes:
Now I try to pass a custom number formatter so as to get rid of the zeroes and it works for that data set
But when I pass all zeroes to a line chart I get an ugly rounding error:
![simulator screen shot jun 10 2016 6 46 35 pm](https://cloud.githubusercontent.com/assets/1481807/15970147/eafa04be-2f3b-11e6-8ea2-24b39efa7165.png)
Is there another way to get rid of the trailing zeroes, or am I doing something wrong?
The text was updated successfully, but these errors were encountered: