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

BarChart right/left bar cut in half #1446

Closed
venux92 opened this issue Sep 15, 2016 · 11 comments
Closed

BarChart right/left bar cut in half #1446

venux92 opened this issue Sep 15, 2016 · 11 comments

Comments

@venux92
Copy link

venux92 commented Sep 15, 2016

Hi, I refer to this issue (closed) similar to my problem.
#323

In BarChart the first and last bar are cut in half.
Is there any solution regarding this ?

Thanks in advance
screen shot 2016-09-15 at 6 06 51 pm

@aoverholtzer
Copy link

I ran into this too and just figured it out: BarChartView has a new property fitBars that defaults to false. Set it to true and your bars are not cut in half.

However, there’s a new problem, at least on my chart: the last bar is entirely missing. I think the problem is in BarChartView.calcMinMax(), which contains:

    if fitBars
    {
        _xAxis.calculate(
            min: data.xMin - data.barWidth / 2.0,
            max: data.xMax - data.barWidth / 2.0)
    }

I think the second (max) calculation should read max: data.xMax + data.barWidth / 2.0.

@venux92
Copy link
Author

venux92 commented Sep 16, 2016

I tried to set fitbars=true but like you I got the last bar missing.

To get the last bar in full, if I set the axisMaximum to +0.5 my max value I got it full but still got the first one "half" even if I set the axisMinimum to -0.5.

If anyone has a solution, thanks in advance.

@liuxuan30
Copy link
Member

What version are you using? Please do try ChartsDemo first to make sure you don't have configuration issue.

@francoisduchemin
Copy link

francoisduchemin commented Sep 23, 2016

I have the same problem. When I set barChartView.fitBars = true the labels are no longer correctly positioned...

With barChartView.fitBars = false: right & left bars are cut in half
simulator screen shot 23 sep 2016 22 44 01

With barChartView.fitBars = true: labels are not correct
simulator screen shot 23 sep 2016 22 43 31

@liuxuan30
Copy link
Member

@francoisduchemin try latest master. I don't see this issue in ChartsDemo

@sree127
Copy link

sree127 commented Sep 28, 2016

@venux92 @francoisduchemin I ran into the same issue even after setting fitBars. It seems settingaxisMaximum was causing the issue. Removing that fixed the issue.

With and without axisMaximum enabled respectively :

Enabled
After removing axisMaximum

@liuxuan30
Copy link
Member

@sree127 you mean xAxis.axisMaximum? I am not sure if it's a bug right now. But taking a look at y axis, if you set axisMaximum, it will be cut by design?

@tuantmdev
Copy link

I ran into a same issue, i didn't customize axisMaximum, tried fitbars = YES but it's not work

Imgur

@francoisduchemin
Copy link

For me the issue was this line:
barChartView.xAxis.setLabelCount(12, force: true)

If I don't put this line, only 6 labels are displayed.
I have changed it to barChartView.xAxis.setLabelCount(12, force: false) and now it works fine :)

@venux92
Copy link
Author

venux92 commented Oct 5, 2016

@sree127 You're right, I remove
xAxis.axisMinimum and xAxis.axisMaximum
I have fitBars=true, If I remove fitBars=true I got the first bar cut in half.
And everything is perfect now

screen shot 2016-10-06 at 5 14 06 am

@liuxuan30
Copy link
Member

Looks like current axisMaximum has bug as #1603 not sure if it's the root cause. But seems you have solved i.t

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