Crash at BarChartRenderer when render bat with multiple data sets
truongtho1603 opened this issue · comments
- I've read, understood, and done my best to follow the *CONTRIBUTING guidelines.
What did you do?
Given that I have an array of BarChartDataSet
which is let dataSets [4 entries, 3 entries, 1 entry]
.
Then I make a BarChartData(dataSets: dataSets)
with that set.
When I render the bar chart with that data set it will crash at BarChartRenderer
.
accessibilityOrderedElements[j/stackSize].append(element)
with an out of exception of index out of range.
What did you expect to happen?
It should not crash.
What happened instead?
I found out that the ChartData > maxEntryCountSet implementation is wrong.
It returns 1 in my example in stead of 4.
I think the fixing should be
/// The DataSet object with the maximum number of entries or null if there are no DataSets.
@objc open var maxEntryCountSet: Element?
{
return self.max { $0.entryCount < $1.entryCount }
}
Charts Environment
Charts version/Branch/Commit Number: 4.0.2
Xcode version: 13.2.1
Swift version: 5.2.4
Platform(s) running Charts: iOS
macOS version running Xcode: 12.3