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

Fatal error when providing multiple data sets in PieChartData #2099

Closed
aubm opened this issue Jan 19, 2017 · 5 comments · Fixed by #2500
Closed

Fatal error when providing multiple data sets in PieChartData #2099

aubm opened this issue Jan 19, 2017 · 5 comments · Fixed by #2500
Labels

Comments

@aubm
Copy link

aubm commented Jan 19, 2017

Hey,

Thank you for open sourcing such a work!
I'm quite new in Swift so I would really appreciate if someone could help me figuring out some strange behavior.

Basically, what I'm trying to do is to initialize a pie chart data with multiple data sets. Here is the code that I use:

pieChart.data = PieChartData(dataSets: [
    PieChartDataSet(values: [PieChartDataEntry(value: 30)], label: "Foo"),
    PieChartDataSet(values: [PieChartDataEntry(value: 70)], label: "Bar")
])

When I do that, I get this error: fatal error: unexpectedly found nil while unwrapping an Optional value.

It seems to happen here, on the second iteration, when i equals 1.

I reproduced it in an example project that can be found here.

Cheers!

@pmairoldi pmairoldi added the bug label Jan 20, 2017
@rjong
Copy link

rjong commented Jan 26, 2017

Ik have the same problem in my project. Waiting on a fix :)

@rjong
Copy link

rjong commented Feb 9, 2017

Is there more information about this bug? Is there a fix?

@aubm
Copy link
Author

aubm commented Feb 9, 2017 via email

@yazankhayyat
Copy link

Hey guys Im experiencing the same issue here, any fix recommendations?

@liuxuan30
Copy link
Member

As far as I remember, pie chart only allow 1 data set.

    open override func getDataSetByIndex(_ index: Int) -> IChartDataSet?
    {
        if index != 0
        {
            return nil
        }
        return super.getDataSetByIndex(index)
    }

liuxuan30 added a commit to liuxuan30/Charts that referenced this issue Jun 5, 2017
liuxuan30 added a commit that referenced this issue Jun 5, 2017
fix #2099, avoid crash when some chart only allow 1 data set
PeterSrost pushed a commit to sokol8/Charts that referenced this issue Oct 31, 2018
PeterSrost pushed a commit to sokol8/Charts that referenced this issue Oct 31, 2018
fix ChartsOrg#2099, avoid crash when some chart only allow 1 data set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants