Skip to content

Commit

Permalink
Make automatically disabling slice-spacing an opt-in feature (#1730)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Oct 31, 2016
1 parent 8ef870a commit ac2050f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion ChartsDemo/Classes/Demos/PieChartViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ - (void)setDataCount:(int)count range:(double)range

NSMutableArray *values = [[NSMutableArray alloc] init];

// IMPORTANT: In a PieChart, no values (Entry) should have the same xIndex (even if from different DataSets), since no values can be drawn above each other.
for (int i = 0; i < count; i++)
{
[values addObject:[[PieChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + mult / 5) label:parties[i % parties.count]]];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ open class PieChartDataSet: ChartDataSet, IPieChartDataSet
_sliceSpace = space
}
}

/// When enabled, slice spacing will be 0.0 when the smallest value is going to be smaller than the slice spacing itself.
open var automaticallyDisableSliceSpacing: Bool = false

/// indicates the selection distance of a pie slice
open var selectionShift = CGFloat(18.0)
Expand Down
3 changes: 3 additions & 0 deletions Source/Charts/Data/Interfaces/IPieChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public protocol IPieChartDataSet: IChartDataSet
/// **maximum**: 20
var sliceSpace: CGFloat { get set }

/// When enabled, slice spacing will be 0.0 when the smallest value is going to be smaller than the slice spacing itself.
var automaticallyDisableSliceSpacing: Bool { get set }

/// indicates the selection distance of a pie slice
var selectionShift: CGFloat { get set }

Expand Down
1 change: 1 addition & 0 deletions Source/Charts/Renderers/PieChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ open class PieChartRenderer: DataRenderer
open func getSliceSpace(dataSet: IPieChartDataSet) -> CGFloat
{
guard
dataSet.automaticallyDisableSliceSpacing,
let viewPortHandler = self.viewPortHandler,
let data = chart?.data as? PieChartData
else { return dataSet.sliceSpace }
Expand Down
3 changes: 3 additions & 0 deletions Source/ChartsRealm/Data/RealmPieDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ open class RealmPieDataSet: RealmBaseDataSet, IPieChartDataSet
}
}

/// When enabled, slice spacing will be 0.0 when the smallest value is going to be smaller than the slice spacing itself.
open var automaticallyDisableSliceSpacing: Bool = false

/// indicates the selection distance of a pie slice
open var selectionShift = CGFloat(18.0)

Expand Down

0 comments on commit ac2050f

Please sign in to comment.