Skip to content

Commit

Permalink
Allow setting the max pie-chart angle
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Dec 16, 2015
1 parent cc0f59d commit 91001c0
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion Charts/Classes/Charts/PieChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public class PieChartView: PieRadarChartViewBase

/// array that holds the absolute angle in degrees of each slice
private var _absoluteAngles = [CGFloat]()

/// maximum angle for this pie
private var _maxAngle: CGFloat = 360.0

public override init(frame: CGRect)
{
Expand Down Expand Up @@ -192,7 +195,7 @@ public class PieChartView: PieRadarChartViewBase
/// calculates the needed angle for a given value
private func calcAngle(value: Double) -> CGFloat
{
return CGFloat(value) / CGFloat(_data.yValueSum) * 360.0
return CGFloat(value) / CGFloat(_data.yValueSum) * _maxAngle
}

public override func indexForAngle(angle: CGFloat) -> Int
Expand Down Expand Up @@ -503,4 +506,29 @@ public class PieChartView: PieRadarChartViewBase
setNeedsDisplay()
}
}

/// The max angle that is used for calculating the pie-circle.
/// 360 means it's a full pie-chart, 180 results in a half-pie-chart.
/// - default: 360.0
public var maxAngle: CGFloat
{
get
{
return _maxAngle
}
set
{
_maxAngle = newValue

if _maxAngle > 360.0
{
_maxAngle = 360.0
}

if _maxAngle < 90.0
{
_maxAngle = 90.0
}
}
}
}

0 comments on commit 91001c0

Please sign in to comment.