After updating to charts 3.2 I started getting Fatal error: Index out of range in the new BarChartRenderer#createAccessibleElement():809. It seems this code dataSet.stackLabels[idx % stackSize] makes stackLabels required?
My workaround for now is to always specify stackLabels. Can be done with something like this:
let dataSet = BarChartDataSet(values: entries, label: nil)
dataSet.stackLabels = [String](repeating: "", count: dataSet.stackSize)
Charts version: 3.2
Xcode version: 10
Swift version: 4.2
Platform: iOS
macOS: 10.13.6
@petester42 may have answer who's responsible for checking the bound for accessibility
+1
1 | Charts | createAccessibleElement (ChartViewBase.swift:47)
2 | Charts | createAccessibleElement (
3 | Charts | drawDataSet (HorizontalBarChartRenderer.swift:280)
4 | Charts | drawData (BarChartRenderer.swift:253)
5 | Charts | draw (BarLineChartViewBase.swift:231)
I also encountered the same problem.
+1
I found this issue too
@simonbengtsson's workaround still fails for me
Sent with GitHawk
I believe I've fixed the issue but we should not allow setting colours/stackLabels individually. There are too many cases where they won't be of the some size but they should be. @liuxuan30, @danielgindi what do you guys think?
I've fixed the crashes but I found some accessibility issue with our current implementation. The fix will take a little longer
We are also facing same issues. Any estimates on fix release?
Problably the end of the week. I鈥檒l see if I have time tomorrow. Please keep in mind that we are all just volunteering our time here.
Hi, im still getting this error when using stacked bar chart. I can provide you with code if it is necessary!
Error:
Thread 1: Fatal error: Index out of range
Where
elementValueText = dataSet.valueFormatter?.stringForValue(
vals[idx % stackSize], <-- HERE
entry: e,
dataSetIndex: dataSetIndex,
viewPortHandler: viewPortHandler) ?? "(e.y)"
Charts Environment
Charts version: 3.2.1
Xcode version: 10
Swift version: 4.2
Platform: iOS
macOS: 10.14
Some sample code to reproduce the issue would be welcomed. Thanks.
Hi, here you go :).
1: https://github.com/Scalman/ChartBug.git
2: pod install
Not Working
3: run project and the error will appear
Working
4: change pod version from 3.2.1 to 3.1.1. Make sure to change swift language version(4) for the pod in the x-code project and run.
Thanks in advance
Also 4 me 馃槥
This is still not fixed by the above commit, using 3.2.1 and latest master both give me the same crash, even if I set the stack labels like suggested in the workaround.
The line crashing is:
elementValueText = dataSet.valueFormatter?.stringForValue(
vals[idx % stackSize],
entry: e,
dataSetIndex: dataSetIndex,
viewPortHandler: viewPortHandler) ?? "\(e.y)"
Specifically, vals[idx % stackSize] is still being called when vals is empty. The other references in this function were fixed, but not this one.
EDIT: Turns out, I'm just an idiot and wasn't passing uniform data along! If you have data that looks like this:
[0.0, 1.0, 2.0, 3.0]
[0.0, 0.0, 1.0, 2.5]
[]
It crashes with out of bounds because I've given it a reason to believe the stack size is 4 and then totally ignored that. On one hand, it would be kind of cool if it handled this, but on the other hand, it's my own fault. Thanks anyway! :)
Hi again,
I have read the comment above from @jboulter11 but what if you want one column with two segments and the other with four? The version 3.1.1 supported this feature. This works fine as long as you have fixed size of segments in each column.
@petester42 what is the status on this issue?
Many thanks again
The status is that I鈥檝e not had the chance to work on it. Been busy. I don鈥檛 see myself being free until after Christmas. If you send a pull request fixing this I鈥檒l review it and release a new version.
Is it easy to fix guys? If so, please create a PR, I can review it soon and add it before next release coming soon.
It was a while ago but i did found some time to fix the issue. @liuxuan30 @petester42 could one of review the small change i did. plz
Most helpful comment
Problably the end of the week. I鈥檒l see if I have time tomorrow. Please keep in mind that we are all just volunteering our time here.