aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Cohen Gindi <danielgindi@gmail.com>2020-01-22 12:46:37 +0200
committerDaniel Cohen Gindi <danielgindi@gmail.com>2020-01-22 12:46:37 +0200
commit58545bbbfa04b053d10784df9e041c4fc3d08b9d (patch)
treedde3c528554c40dd5d1ca804ac53a07c1dd719f3
parent4ce14e6cc90fbe8706fb4d0c5fbec4184927f6c3 (diff)
downloadMPAndroidChart-58545bbbfa04b053d10784df9e041c4fc3d08b9d.tar.gz
Add option to disable clipping data to contentRect
https://github.com/danielgindi/Charts/pull/3360
-rw-r--r--MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java31
-rw-r--r--MPChartLib/src/main/java/com/github/mikephil/charting/data/PieData.java2
2 files changed, 30 insertions, 3 deletions
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java
index c7a59373..0926dff2 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/BarLineChartBase.java
@@ -100,6 +100,8 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
protected boolean mClipValuesToContent = false;
+ protected boolean mClipDataToContent = true;
+
/**
* Sets the minimum offset (padding) around the chart, defaults to 15
*/
@@ -230,9 +232,12 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
if (mAxisRight.isEnabled() && mAxisRight.isDrawLimitLinesBehindDataEnabled())
mAxisRendererRight.renderLimitLines(canvas);
- // make sure the data cannot be drawn outside the content-rect
int clipRestoreCount = canvas.save();
- canvas.clipRect(mViewPortHandler.getContentRect());
+
+ if (isClipDataToContentEnabled()) {
+ // make sure the data cannot be drawn outside the content-rect
+ canvas.clipRect(mViewPortHandler.getContentRect());
+ }
mRenderer.drawData(canvas);
@@ -1229,6 +1234,17 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
}
/**
+ * When disabled, the data and/or highlights will not be clipped to contentRect. Disabling this option can
+ * be useful, when the data lies fully within the content rect, but is drawn in such a way (such as thick lines)
+ * that there is unwanted clipping.
+ *
+ * @param enabled
+ */
+ public void setClipDataToContent(boolean enabled) {
+ mClipDataToContent = enabled;
+ }
+
+ /**
* When enabled, the values will be clipped to contentRect,
* otherwise they can bleed outside the content rect.
*
@@ -1239,6 +1255,17 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
}
/**
+ * When disabled, the data and/or highlights will not be clipped to contentRect. Disabling this option can
+ * be useful, when the data lies fully within the content rect, but is drawn in such a way (such as thick lines)
+ * that there is unwanted clipping.
+ *
+ * @return
+ */
+ public boolean isClipDataToContentEnabled() {
+ return mClipDataToContent;
+ }
+
+ /**
* Sets the width of the border lines in dp.
*
* @param width
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieData.java b/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieData.java
index 96667aed..423ce19b 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieData.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/data/PieData.java
@@ -56,7 +56,7 @@ public class PieData extends ChartData<IPieDataSet> {
Log.e("MPAndroidChart",
"Found multiple data sets while pie chart only allows one");
}
-
+
return dataSets;
}