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

[Chart 3.0 BUG] xAxis labels disappear after a deep zoom in #1564

Closed
liuxuan30 opened this issue Sep 27, 2016 · 4 comments
Closed

[Chart 3.0 BUG] xAxis labels disappear after a deep zoom in #1564

liuxuan30 opened this issue Sep 27, 2016 · 4 comments

Comments

@liuxuan30
Copy link
Member

liuxuan30 commented Sep 27, 2016

xAxis labels disappear after a deep zoom in
Step to reproduce:

  1. Open ChartsDemo Time Line Chart
  2. zoom in a lot, until the xAxis label disappears

After triage, I found there are two issues:
1: centerAxisLabelsEnabled will be false after entryCount = 1.
Change to below, xAxis.entries will have only 1 entry after zoom in.

    open var centerAxisLabelsEnabled: Bool
    {
        get { return _centerAxisLabelsEnabled && entryCount > 0 }
    }

2: I found in

open func computeAxisValues(min: Double, max: Double)
    ...
    let last = interval == 0.0 ? 0.0 : ChartUtils.nextUp(floor(yMax / interval) * interval
    if interval != 0.0 && last != first // condition is false due to last equals first now
    {
        for _ in stride(from: first, through: last, by: interval)
        {
            n += 1
        }
    }
    ...

After zoom in a lot first and last are the same value, causing n to be default value, which is 1 (centerAxisLabelsEnabled is 1 now instead of 0 because above code change in # 1)

liuxuan30 added a commit to liuxuan30/Charts that referenced this issue Sep 27, 2016
1. use axis.centerAxisLabelsEnabled instead of local variable to avoid dirty read
2. fix xAxis label missing issue
@danielgindi
Copy link
Collaborator

That is fixed. However, you should limit the maximum zoom in to a reasonable number.
If the zoom is in to a position where the difference between two axis labels is "0.000000000000001", it's not a zoom that is useful to the user.

@danielgindi
Copy link
Collaborator

danielgindi commented Sep 29, 2016

I guess that by "deep zoom in" you are referring to a zoom so deep the the distance between two labels is zero or close to zero. That's not a usable zoom anyway. Please limit the max zoom in available to the user.

EDIT: Yeah, I meant "Infinite", and for some reason said "zero"

@liuxuan30
Copy link
Member Author

liuxuan30 commented Sep 30, 2016

'deep zoom in' means zoom in until you can't see any data entry in a line chart, or in bar chart, zoom in that the view can't hold a single bar.
It's not a usable zoom yes, but guessing if we could do that :)

@castus
Copy link

castus commented Aug 5, 2017

I have the same problem, I have three bars with points (x: 0, y: 1), (x: 1, y: 2), (x: 2, y: 3) and when I'm zooming the whole bar disappears. The same with labels, they disappears even earlier than bars. How to prevent this?

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