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

Line chart yAxis data interval #912

Closed
ergihervi opened this issue Apr 3, 2016 · 7 comments
Closed

Line chart yAxis data interval #912

ergihervi opened this issue Apr 3, 2016 · 7 comments

Comments

@ergihervi
Copy link

Hi! I have a problem with the 'y' data interval. Before to update, the intervals where the same:

captura de pantalla 2016-04-02 a las 7 33 24 p m

0+3 = 3
3+3 = 6
6+3 = 9
9+3 = 12
12+3 = 15

And now, the intervals are different:
captura de pantalla 2016-04-02 a las 6 28 21 p m

0+3 = 3
3+4 = 7
7+3 = 10
10+4 = 14
14+3 = 17

Also, it used to have a little space between the last value and the top of the graph view.

How could I fix this? here is my code from the left axis:

let leftAxis = graphView.leftAxis
leftAxis.drawGridLinesEnabled = false
leftAxis.labelFont = UIFont.systemFontOfSize(10)
leftAxis.valueFormatter = yFormatter
leftAxis.forceLabelsEnabled = true
leftAxis.axisMinValue = 0

@ergihervi ergihervi changed the title Line chart yAxis data Line chart yAxis data interval Apr 3, 2016
@danielgindi
Copy link
Collaborator

Seems like the range of the data changed, or the zoom, or maybe the size of the device you're testing?

@ergihervi
Copy link
Author

No, is the same data, same phone, same graph view size (no zoom) :S

@liuxuan30
Copy link
Member

how about the formatter? You are using a percent style. the interval should not change at all. change to decimal style to see how the number is.

@liuxuan30
Copy link
Member

@ergihervi for the space, There is a small algorithm calcuating the range in computeAxisValues() of y axis renderer.
If you are not setting any extraTopOffset,
from your 2 charts, the y axis line is at different length, so my guess is the first chart has a 18% label beyond the top, and being clipped, while the second chart y max is 17%.
I don't know how you 'update' it, but it looks like computeAxisValues() calculated two different ranges.

I wish you could debug this on your side in computeAxisValues(), that may tell you if the two ranges are really changed.

@ergihervi
Copy link
Author

@liuxuan30 Thanks for your answer! I updated to swift 2.2 and the last 'Charts' update. I didn't set the extra top off set before, but it looks that I have to do it now in order to have a little space from the last yValue to the top (Just found how to do this).

I printed the left axis entries, and this was the result: [0.0, 0.033846153846153845, 0.067692307692307691, 0.10153846153846154, 0.13538461538461538, 0.16923076923076924]. I guess the size of the number is the problem, this probably could be fixed in the algorithm that calculates this values by (maybe) formatting the value that is being added? e.g. "0.033846153846153845" to "0.03"

@liuxuan30
Copy link
Member

not really, while calculating the number is the number, no need to round (even you round, there's still the same issue). It's the value formatter that causes this, as you see 0.0338 -> 3% and 0.067 -> 7%, 0.101-> 10%. You can write your own formatter to solve this.

I'm going to close this, since it's releated to formatter.

@liuxuan30
Copy link
Member

@danielgindi Actually, what you think we limit the decimals to some digits? Like adding a property to specify how many digits we want to keep? So we only keep them. e.g. if we specify maxDigits = 2, 0.0338 -> 0.03, 0.067 -> 0.06, we don't do round at all. just abandon the addtional portion directly. That looses accuracy but it's user's choice.

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

3 participants