Skip to content

Commit

Permalink
Allow the minimum offset for BarLine and PieRadar charts to be custom…
Browse files Browse the repository at this point in the history
…ized
  • Loading branch information
icecrystal23 committed Sep 22, 2015
1 parent 7b85077 commit 26b03da
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
15 changes: 8 additions & 7 deletions Charts/Classes/Charts/BarLineChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate

/// Sets drawing the borders rectangle to true. If this is enabled, there is no point drawing the axis-lines of x- and y-axis.
public var drawBordersEnabled = false

/// Sets the minimum offset (padding) around the chart, defaults to 10
public var minOffset = CGFloat(10.0)

/// the object representing the labels on the y-axis, this object is prepared
/// in the pepareYLabels() method
Expand Down Expand Up @@ -446,14 +449,12 @@ public class BarLineChartViewBase: ChartViewBase, UIGestureRecognizerDelegate
offsetRight += self.extraRightOffset
offsetBottom += self.extraBottomOffset
offsetLeft += self.extraLeftOffset

let minOffset = CGFloat(10.0)


_viewPortHandler.restrainViewPort(
offsetLeft: max(minOffset, offsetLeft),
offsetTop: max(minOffset, offsetTop),
offsetRight: max(minOffset, offsetRight),
offsetBottom: max(minOffset, offsetBottom))
offsetLeft: max(self.minOffset, offsetLeft),
offsetTop: max(self.minOffset, offsetTop),
offsetRight: max(self.minOffset, offsetRight),
offsetBottom: max(self.minOffset, offsetBottom))
}

prepareOffsetMatrix()
Expand Down
13 changes: 7 additions & 6 deletions Charts/Classes/Charts/PieRadarChartViewBase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public class PieRadarChartViewBase: ChartViewBase
/// flag that indicates if rotation is enabled or not
public var rotationEnabled = true

/// Sets the minimum offset (padding) around the chart, defaults to 10
public var minOffset = CGFloat(10.0)

private var _rotationWithTwoFingers = false

private var _tapGestureRecognizer: UITapGestureRecognizer!
Expand Down Expand Up @@ -188,8 +191,6 @@ public class PieRadarChartViewBase: ChartViewBase
legendRight += self.extraRightOffset
legendBottom += self.extraBottomOffset
legendLeft += self.extraLeftOffset

var minOffset = CGFloat(10.0)

if (self.isKindOfClass(RadarChartView))
{
Expand All @@ -201,10 +202,10 @@ public class PieRadarChartViewBase: ChartViewBase
}
}

let offsetLeft = max(minOffset, legendLeft)
let offsetTop = max(minOffset, legendTop)
let offsetRight = max(minOffset, legendRight)
let offsetBottom = max(minOffset, max(self.requiredBaseOffset, legendBottom))
let offsetLeft = max(self.minOffset, legendLeft)
let offsetTop = max(self.minOffset, legendTop)
let offsetRight = max(self.minOffset, legendRight)
let offsetBottom = max(self.minOffset, max(self.requiredBaseOffset, legendBottom))

_viewPortHandler.restrainViewPort(offsetLeft: offsetLeft, offsetTop: offsetTop, offsetRight: offsetRight, offsetBottom: offsetBottom)
}
Expand Down

0 comments on commit 26b03da

Please sign in to comment.