Skip to content

Commit ab66734

Browse files
authored
Merge pull request #5231 from StainlessStlRat/master
Fix crash in LineChartRenderer.swift when animating data set changes
2 parents 82271c7 + 04aeec5 commit ab66734

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Source/Charts/Renderers/LineChartRenderer.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,12 @@ open class LineChartRenderer: LineRadarRenderer
760760

761761
for high in indices
762762
{
763+
// When updating the data set for the chart and then animating it, sometimes highlights are generated for the
764+
// removed sets. This guard prevents OOB in the case where the new set has less data than the old set
765+
if high.dataSetIndex >= lineData._dataSets.count - 1 {
766+
continue
767+
}
768+
763769
guard let set = lineData[high.dataSetIndex] as? LineChartDataSetProtocol,
764770
set.isHighlightEnabled
765771
else { continue }

0 commit comments

Comments
 (0)