Skip to content

Commit

Permalink
Make automatically disabling slice-spacing an opt-in feature
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Oct 31, 2016
1 parent 9a19bf6 commit fb8094e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class PieDataSet extends DataSet<PieEntry> implements IPieDataSet {

/** the space in pixels between the chart-slices, default 0f */
private float mSliceSpace = 0f;
private boolean mAutomaticallyDisableSliceSpacing;

/** indicates the selection distance of a pie slice */
private float mShift = 18f;
Expand Down Expand Up @@ -75,6 +76,27 @@ public float getSliceSpace() {
return mSliceSpace;
}

/**
* When enabled, slice spacing will be 0.0 when the smallest value is going to be
* smaller than the slice spacing itself.
*
* @param autoDisable
*/
public void setAutomaticallyDisableSliceSpacing(boolean autoDisable) {
mAutomaticallyDisableSliceSpacing = autoDisable;
}

/**
* When enabled, slice spacing will be 0.0 when the smallest value is going to be
* smaller than the slice spacing itself.
*
* @return
*/
@Override
public boolean isAutomaticallyDisableSliceSpacing() {
return mAutomaticallyDisableSliceSpacing;
}

/**
* sets the distance the highlighted piechart-slice of this DataSet is
* "shifted" away from the center of the chart, default 12f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ public interface IPieDataSet extends IDataSet<PieEntry> {
*/
float getSliceSpace();

/**
* When enabled, slice spacing will be 0.0 when the smallest value is going to be
* smaller than the slice spacing itself.
*
* @return
*/
boolean isAutomaticallyDisableSliceSpacing();

/**
* Returns the distance a highlighted piechart slice is "shifted" away from
* the chart-center in dp.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ protected float calculateMinimumRadiusForSpacedSlice(
*/
protected float getSliceSpace(IPieDataSet dataSet) {

if (!dataSet.isAutomaticallyDisableSliceSpacing())
return dataSet.getSliceSpace();

float spaceSizeRatio = dataSet.getSliceSpace() / mViewPortHandler.getSmallestContentExtension();
float minValueRatio = dataSet.getYMin() / mChart.getData().getYValueSum() * 2;

Expand Down

0 comments on commit fb8094e

Please sign in to comment.