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

BUG::: leftAxis.axisMinValue !!!=== 0.0 #1101

Closed
dsencheng opened this issue Jun 2, 2016 · 5 comments
Closed

BUG::: leftAxis.axisMinValue !!!=== 0.0 #1101

dsencheng opened this issue Jun 2, 2016 · 5 comments

Comments

@dsencheng
Copy link

qq20160602-0 2x

@liuxuan30
Copy link
Member

Please be more specific how this happens in your first three charts. Usually you should see it's fine. Have you call notifyDataSetChanged after you set leftAxis.axisMinValue?

@dsencheng
Copy link
Author

dsencheng commented Jun 2, 2016

@liuxuan30 可以中文描述么? 在BarChartViewController.m 75行 注释掉leftAxis.axisMinValue = 0.0,然后运行,不停的push和pop操作,每次出现的底部高度不一样。预期的是一直在X轴上。

Translated by @liuxuan30:
If we comment out BarChartViewController - Line 75: leftAxis.axisMinValue = 0.0
while pushing and poping the bar chart, the minimum y value seems changing, not right on the x axie zero line.

@liuxuan30
Copy link
Member

liuxuan30 commented Jun 2, 2016

@dsencheng I encourage you use English, because more people can help you. I have added a translation.

Now back to the topic: I'm not sure if this is a bug or not.

By default, if you do nothing, the y axis range is calculated via y axis renderer's computeAxisValues(), it takes yMin and yMax as arguments. In ChartYAxis, calculate() is calculating _axisMinimum, which is yMin later.

Now in your case, you let the library calculate y axis range for you, so it will go to:

        // bottom-space only effects non-custom min
        if !_customAxisMin
        {
            let bottomSpace = range * Double(spaceBottom)
            _axisMinimum = min - bottomSpace
        }

and axisMinimum is a small negative now. So, if you want to always start from zero, you should explicitly call leftAxis.axisMinValue = 0.0

@dsencheng
Copy link
Author

@liuxuan30 抱歉,英文实在不好。我还是用中文描述下好了。这个问题是柱状图底部不在X轴上,它偏移了。我希望柱状图固定在X轴上,并且我不需要设置axisMinValue = 0.0

@liuxuan30
Copy link
Member

if you want to make bar stay right on x axis, you have to set axisMinValue = 0.0

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