Skip to content

Commit

Permalink
Avoid division by zeros (Fixes #946)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Apr 13, 2016
1 parent c5896b6 commit f7cf599
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Charts/Classes/Utils/ChartViewPortHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,14 @@ public class ChartViewPortHandler: NSObject
/// Sets the maximum scale factor for the x-axis
public func setMaximumScaleX(xScale: CGFloat)
{
_maxScaleX = xScale
var newValue = xScale

if (newValue == 0.0)
{
newValue = CGFloat.max
}

_maxScaleX = newValue

limitTransAndScale(matrix: &_touchMatrix, content: _contentRect)
}
Expand All @@ -325,11 +332,16 @@ public class ChartViewPortHandler: NSObject
public func setMinMaxScaleX(minScaleX minScaleX: CGFloat, maxScaleX: CGFloat)
{
var newMin = minScaleX
var newMax = minScaleY

if (newMin < 1.0)
{
newMin = 1.0
}
if (newMax == 0.0)
{
newMax = CGFloat.max
}

_minScaleX = newMin
_maxScaleX = maxScaleX
Expand All @@ -355,7 +367,14 @@ public class ChartViewPortHandler: NSObject
/// Sets the maximum scale factor for the y-axis
public func setMaximumScaleY(yScale: CGFloat)
{
_maxScaleY = yScale
var newValue = yScale

if (newValue == 0.0)
{
newValue = CGFloat.max
}

_maxScaleY = newValue

limitTransAndScale(matrix: &_touchMatrix, content: _contentRect)
}
Expand Down

0 comments on commit f7cf599

Please sign in to comment.