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

Bar Chart Drawing is wrong without setting axisminimum #3751

Closed
laurentmorvillier opened this issue Nov 20, 2018 · 9 comments
Closed

Bar Chart Drawing is wrong without setting axisminimum #3751

laurentmorvillier opened this issue Nov 20, 2018 · 9 comments

Comments

@laurentmorvillier
Copy link

What did you do?

Hello, I've built the following graph using iOS Charts and this dataset:
d1

Here is what I get with my current code:
g2
The selection selects the correct value but all bars have the same size

What did you expect to happen?

Now if I add the following line:
self.leftAxis.axisMinimum = -1140.0

The chart is correctly drawn:
g1

Are we expected to dynamically set the axisMinimum at all times? Graphs with positive and negative are correctly drawn, but it looks like positive only dataset or negative only datasets requires an axisMinimum.

Charts Environment

Charts version/Branch/Commit Number: 3.2.1
Xcode version: 10
Swift version: 4.2
Platform(s) running Charts:
macOS version running Xcode:

@zhihengcheung
Copy link

the demo don’t set axisMinimum is ok.i copy demo into my project, it dosen’t work,i don’t understand

@zhihengcheung
Copy link

i found solution,copy demo charts source cover your project source,it,ok

@laurentmorvillier
Copy link
Author

laurentmorvillier commented Nov 21, 2018

I reproduce the issue in AnotherBarChartViewController, project attached

func setDataCount(_ count: Int, range: Double) {
    
    var yVals: [BarChartDataEntry] = []
    let values: [Double] = [-90, -700, -130, -150, -565, -550, -1140]
    for (i, v) in values.enumerated() {
        yVals.append(BarChartDataEntry(x: Double(i), y: v))
    }

// let yVals = (0..<count).map { (i) -> BarChartDataEntry in
// let mult = range + 1
// let val = Double(arc4random_uniform(UInt32(mult))) + mult/3
// return BarChartDataEntry(x: Double(i), y: val)
// }

ChartsDemo-iOS.zip

simulator screen shot - iphone 8 - 2018-11-21 at 10 46 29

@liuxuan30
Copy link
Member

this should be tested already with recent fix. have you called chartView.dataSetChanged after you call self.leftAxis.axisMinimum = -1140.0?

@liuxuan30
Copy link
Member

sorry it's a bit confusing about your issue. I will take a look

@liuxuan30
Copy link
Member

Hey, I grabbed your code from Another Bar Chart, it's drawing fine:
image

I guess you need to update your library. We recently had a fix about negative bars, not sure if the bug impact you as well, but currently it's drawing fine.

@laurentmorvillier
Copy link
Author

Hey liuxuan30, thanks for your help. Updating did fix the problem!
May I ask why don't you bump the version after fixes? This could help avoiding such situation

@liuxuan30
Copy link
Member

we had a release already. but we usually push a new version when Xcode require changes, or we had major updates. just bug fixes are not enough for a release I suppose.

@liuxuan30
Copy link
Member

liuxuan30 commented Dec 4, 2018

my advice would be use source code directly; it's easier to change. if you use pods or carthage, no problem, but fixing issues would be harder compared to source code. You could also point to master for carthage and pods

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