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

Allow the minimum offset to be customized #395

Merged
Merged
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
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