Skip to content

Commit 6d1cdfe

Browse files
committed
Charts/issues/5197 - fixed host app crash by checking if the value is not NAN
1 parent 9d3e924 commit 6d1cdfe

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

Source/Charts/Renderers/BarLineScatterCandleBubbleRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ open class BarLineScatterCandleBubbleRenderer: NSObject, DataRenderer
6767
{
6868
guard let data = dataProvider?.data else { return false }
6969
let count = CGFloat(dataProvider?.maxVisibleCount ?? 0) * viewPortHandler.scaleX
70-
guard count < CGFloat.infinity else { return false }
70+
guard count < CGFloat.infinity, !count.isNaN else { return false }
7171
return data.entryCount < Int(count)
7272
}
7373

Source/Charts/Renderers/CombinedChartRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ open class CombinedChartRenderer: NSObject, DataRenderer
163163
{
164164
guard let data = dataProvider?.data else { return false }
165165
let count = CGFloat(dataProvider?.maxVisibleCount ?? 0) * viewPortHandler.scaleX
166-
guard count < CGFloat.infinity else { return false }
166+
guard count < CGFloat.infinity, !count.isNaN else { return false }
167167
return data.entryCount < Int(count)
168168
}
169169

Source/Charts/Renderers/HorizontalBarChartRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ open class HorizontalBarChartRenderer: BarChartRenderer
616616
{
617617
guard let data = dataProvider?.data else { return false }
618618
let count = CGFloat(dataProvider?.maxVisibleCount ?? 0) * viewPortHandler.scaleX
619-
guard count < CGFloat.infinity else { return false }
619+
guard count < CGFloat.infinity, !count.isNaN else { return false }
620620
return data.entryCount < Int(count)
621621
}
622622

Source/Charts/Renderers/PieChartRenderer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ open class PieChartRenderer: NSObject, DataRenderer
590590
{
591591
guard let data = dataProvider?.data else { return false }
592592
let count = CGFloat(dataProvider?.maxVisibleCount ?? 0) * viewPortHandler.scaleX
593-
guard count < CGFloat.infinity else { return false }
593+
guard count < CGFloat.infinity, !count.isNaN else { return false }
594594
return data.entryCount < Int(count)
595595
}
596596

0 commit comments

Comments
 (0)