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

Crash on one entry point in charts #265

Closed
amycheong19 opened this issue Aug 3, 2015 · 9 comments
Closed

Crash on one entry point in charts #265

amycheong19 opened this issue Aug 3, 2015 · 9 comments

Comments

@amycheong19
Copy link

Hi all, I noticed when there is ok one entry point for the chart and it crash with error: (EXC_BAD_INSTRUCTION) at

public override var highestVisibleXIndex: Int
{
    var step = CGFloat(_data.dataSetCount)
    var div = (step <= 1.0) ? 1.0 : step + (_data as! BarChartData).groupSpace

    var pt = CGPoint(x: _viewPortHandler.contentRight, y: _viewPortHandler.contentBottom)
    getTransformer(ChartYAxis.AxisDependency.Left).pixelToValue(&pt)

    ////>>>> crash at this line >>>>>
    return Int((pt.x >= CGFloat(chartXMax)) ? CGFloat(chartXMax) / div : (pt.x / div))
 }

I found out that the point end up display (nan, nan) thus the error. Is there a precaution or workaround for this?

@liuxuan30
Copy link
Member

you have to give more information why it is (nan,nan). I met such issues from time to time, and I found it's my fault to feed invalid numbers like nan, like divide 0.

Usually it is your duty to make sure all the data you passed through is valid. If it is a bug, you might need to provde the test data so we can reproduce it. Generally above code seems fine.

@amycheong19
Copy link
Author

It only happen when I have one entry point for the graph. Before the line method "getTransformer" my pt. returns (356, 10), after that pt becomes (nan, nan)
I can assure my value pass in are double values combined chart

@liuxuan30
Copy link
Member

only one entry point should not be the problem. What's the dataSet code and the view bounds?

@danielgindi
Copy link
Collaborator

Please state the version you are using, and show the dataset that crashes.

@danielgindi
Copy link
Collaborator

I do not experience any crash with 1 bar. There was a random crash with zero bars which was just fixed.
The last response from @amycheong19 was 23 days ago so I'm assuming he is not experiencing this either.

@mlorenzeCDS
Copy link

I have the same crash when the set has all values with the same value (zeros, ones, etc)

@liuxuan30
Copy link
Member

@mlorenzeCDS what chart and what data can we reproduce?

@mlorenzeCDS
Copy link

mlorenzeCDS commented Jul 11, 2016

I found the solution. The problem was when the dataset has all values equals to zero in Wave Chart.
I had to update the class ChartDataSet.swift (specially the method calcMinMax setting the yMax var with -DBL_MIN)

Thanks!

@liuxuan30
Copy link
Member

@danielgindi are you aware of this zero issue?

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

4 participants