Make automatically disabling slice-spacing an opt-in feature
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieDataSet.java b/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieDataSet.java
index 3e864a2..229ed53 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieDataSet.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieDataSet.java
@@ -11,6 +11,7 @@
/** 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;
@@ -76,6 +77,27 @@
}
/**
+ * 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
*
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IPieDataSet.java b/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IPieDataSet.java
index 3b10d00..aa1c575 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IPieDataSet.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/interfaces/datasets/IPieDataSet.java
@@ -18,6 +18,14 @@
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.
*
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/PieChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/PieChartRenderer.java
index 1681d5b..3c52f7c 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/PieChartRenderer.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/PieChartRenderer.java
@@ -199,6 +199,9 @@
*/
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;