-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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: Index out of range from subscript(position: Index) -> Element #4024
Comments
I think you should check your data first, I'm not sure if it's our bug. If you sure, you should provide data code so we can reproduce with ChartsDemo. Otherwise we will think it's your issue, as OOB could go very wild. reopen when you have details we could reproduce |
I've been dealing with this issue all week and finally found a fix, so hopefully I can help. I'm working on a similar app and getting the same crash. It can be reproduced by adding 10,000 entries to the chart right away (I was using a line graph and 3 data sets), and the crash happens soon (or immediately) after. I'm running my app on a really old iPhone. But I think the library has an issue with some internal function when you get this many entries, where it slows down and tries to get an invalid index after waiting too long. That's just a guess. I fixed it by deleting old entries so that the number didn't pile up, and kept it limited to a certain max number of entries. In my case, I was trying to add 30 entries per second, and it would crash after only 5 minutes, so thankfully having the crash in only 5 minutes helped me to figure out what was causing this. I hope that helps. I'm not sure what the best way to fix that would be, but at least a warning when there are too many entries for it to handle would have saved me a lot of headache. |
I also have the same issue as @tnmendes mentioned |
I think i found the reason, before i do the setChartData() i am running this function clearChartValues().
|
|
I finally found the problem and how to replicate and solution :D Analyzing the last crash I understood that the problem was the highlight value on the chart: I have a graph where the x is timeIntervalSince1970 and the granularity in 3 of them is daily and in the last tab it is monthly. The solution to this problem is when you are doing a set chart with new data, force it to @liuxuan30 Do you think you can do something to prevent this from happening? |
Thank you so much, I have the same problem on Charts version 5.0.0. |
I was facing the same fatal error while using bar and line charts on the same screen and I frequently updated its data source, while I also added some markers on both, but @tnmendes 's solution just saved my day! I added those lines before updating the data source. barChartView.highlightValues(nil)
lineChartView.highlightValues(nil)
barChartView.marker = nil
lineChartView.marker = nil |
What did you do?
I have an application that is live updating a chart. Its getting temperature values once per second and graphing them. After about 15 Hours I am getting a crash. Fatal error: Index out of range.
Crash is coming from ChartDataSet.swift file.
}
My 'position' value at this point is 3754, so I know it has a value.
My 'entries' array has 4364 values in it at this point and the 3754 location does have data in it.
What did you expect to happen?
This should not be out of range. The entries array length is much longer than 3754 and it has values in it.
What happened instead?
Fatal error: Index out of range
Charts Environment
Charts version/Branch/Commit Number:. Version 3.3.0
Xcode version:. 10.2.1
Swift version: 4.2
Platform(s) running Charts: Mac OSX Mojave
macOS version running Xcode:. 10.14.5
The text was updated successfully, but these errors were encountered: