Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Charts/issues/5197 - fixed host app crash by adding a check before ca… #5198

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ open class BarLineScatterCandleBubbleRenderer: NSObject, DataRenderer
open func isDrawingValuesAllowed(dataProvider: ChartDataProvider?) -> Bool
{
guard let data = dataProvider?.data else { return false }
return data.entryCount < Int(CGFloat(dataProvider?.maxVisibleCount ?? 0) * viewPortHandler.scaleX)
let count = CGFloat(dataProvider?.maxVisibleCount ?? 0) * viewPortHandler.scaleX
guard count < CGFloat.infinity, !count.isNaN else { return false }
return data.entryCount < Int(count)
}

/// Class representing the bounds of the current viewport in terms of indices in the values array of a DataSet.
Expand Down
4 changes: 3 additions & 1 deletion Source/Charts/Renderers/CombinedChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ open class CombinedChartRenderer: NSObject, DataRenderer
open func isDrawingValuesAllowed(dataProvider: ChartDataProvider?) -> Bool
{
guard let data = dataProvider?.data else { return false }
return data.entryCount < Int(CGFloat(dataProvider?.maxVisibleCount ?? 0) * viewPortHandler.scaleX)
let count = CGFloat(dataProvider?.maxVisibleCount ?? 0) * viewPortHandler.scaleX
guard count < CGFloat.infinity, !count.isNaN else { return false }
return data.entryCount < Int(count)
}

/// All sub-renderers.
Expand Down
7 changes: 4 additions & 3 deletions Source/Charts/Renderers/HorizontalBarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,10 @@ open class HorizontalBarChartRenderer: BarChartRenderer

open override func isDrawingValuesAllowed(dataProvider: ChartDataProvider?) -> Bool
{
guard let data = dataProvider?.data
else { return false }
return data.entryCount < Int(CGFloat(dataProvider?.maxVisibleCount ?? 0) * self.viewPortHandler.scaleY)
guard let data = dataProvider?.data else { return false }
let count = CGFloat(dataProvider?.maxVisibleCount ?? 0) * viewPortHandler.scaleX
guard count < CGFloat.infinity, !count.isNaN else { return false }
return data.entryCount < Int(count)
}

/// Sets the drawing position of the highlight object based on the riven bar-rect.
Expand Down
4 changes: 3 additions & 1 deletion Source/Charts/Renderers/PieChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,9 @@ open class PieChartRenderer: NSObject, DataRenderer
open func isDrawingValuesAllowed(dataProvider: ChartDataProvider?) -> Bool
{
guard let data = dataProvider?.data else { return false }
return data.entryCount < Int(CGFloat(dataProvider?.maxVisibleCount ?? 0) * viewPortHandler.scaleX)
let count = CGFloat(dataProvider?.maxVisibleCount ?? 0) * viewPortHandler.scaleX
guard count < CGFloat.infinity, !count.isNaN else { return false }
return data.entryCount < Int(count)
}

/// draws the hole in the center of the chart and the transparent circle / hole
Expand Down