Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Crash at BarChartRenderer when render bat with multiple data sets #4821

Description

@truongtho1603

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions