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

Re: Fatal error while loading Bar Chart #1511 #1517

Closed
codyfazio opened this issue Sep 21, 2016 · 5 comments
Closed

Re: Fatal error while loading Bar Chart #1511 #1517

codyfazio opened this issue Sep 21, 2016 · 5 comments

Comments

@codyfazio
Copy link

codyfazio commented Sep 21, 2016

I'm sorry, it looks like the problem persists. I actually tried adding the new check in before I posted last time, but was still having issues. My number seems to be fine, but the value returned from roundToNextSignificant() is Inf, which is causing the crash. Should another check be performed after the value comes back?

internal class func roundToNextSignificant(number: Double) -> Double
{
if number.isInfinite || number.isNaN || number == 0
{
return number
}

    let d = ceil(log10(number < 0.0 ? -number : number))
    let pw = 1 - Int(d)
    let magnitude = pow(Double(10.0), Double(pw))
    let shifted = round(number * magnitude)
    return shifted / magnitude
}

internal class func decimals(_ number: Double) -> Int
{
    if number.isInfinite || number.isNaN || number == 0
    {
        return 0
    }

    let i = roundToNextSignificant(number: Double(number))
    return Int(ceil(-log10(i))) + 2
}
@danielgindi
Copy link
Collaborator

Why didn't you just re-open the issue?...

@danielgindi
Copy link
Collaborator

What exactly is your setup? As we do not see any reason for an Infinite value to get in there

@danielgindi
Copy link
Collaborator

Please do some debugging. There are safeguard in place, like checking for labelCount == 0 etc. Shouldn't happen.

@codyfazio
Copy link
Author

Sorry, this is my first time posting an issue. I didn't realize I could reopen one. I've been trying to figure this out for 3 days, because I assumed it was something on my end. I thought maybe if I reached out, you might have some insight. I've been using the framework for months, and it's only until the change to Swift 3 that it started crashing.

@codyfazio
Copy link
Author

I figured it out. During the migration my chartDataSet was cast as IChartDataSet. Removing the cast fixed the issue. Thanks for your help and sorry to bother.

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