Fix #1978
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java
index cffcc1c..3260d4c 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarChartRenderer.java
@@ -74,7 +74,7 @@
IBarDataSet set = barData.getDataSetByIndex(i);
- if (set.isVisible() && set.getEntryCount() > 0) {
+ if (set.isVisible()) {
drawDataSet(c, set, i);
}
}
@@ -195,7 +195,7 @@
IBarDataSet dataSet = dataSets.get(i);
- if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)
+ if (!shouldDrawValues(dataSet))
continue;
// apply the text-styling defined by the DataSet
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarLineScatterCandleBubbleRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarLineScatterCandleBubbleRenderer.java
index aa400ca..8f2447d 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarLineScatterCandleBubbleRenderer.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BarLineScatterCandleBubbleRenderer.java
@@ -5,6 +5,7 @@
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.interfaces.dataprovider.BarLineScatterCandleBubbleDataProvider;
import com.github.mikephil.charting.interfaces.datasets.IBarLineScatterCandleBubbleDataSet;
+import com.github.mikephil.charting.interfaces.datasets.IDataSet;
import com.github.mikephil.charting.utils.ViewPortHandler;
/**
@@ -12,7 +13,9 @@
*/
public abstract class BarLineScatterCandleBubbleRenderer extends DataRenderer {
- /** buffer for storing the current minimum and maximum visible x */
+ /**
+ * buffer for storing the current minimum and maximum visible x
+ */
protected XBounds mXBounds = new XBounds();
public BarLineScatterCandleBubbleRenderer(ChartAnimator animator, ViewPortHandler viewPortHandler) {
@@ -20,6 +23,16 @@
}
/**
+ * Returns true if the DataSet values should be drawn, false if not.
+ *
+ * @param set
+ * @return
+ */
+ protected boolean shouldDrawValues(IDataSet set) {
+ return set.isVisible() && set.isDrawValuesEnabled();
+ }
+
+ /**
* Checks if the provided entry object is in bounds for drawing considering the current animation phase.
*
* @param e
@@ -66,7 +79,7 @@
* @param chart
* @param dataSet
*/
- public void set(BarLineScatterCandleBubbleDataProvider chart, IBarLineScatterCandleBubbleDataSet dataSet){
+ public void set(BarLineScatterCandleBubbleDataProvider chart, IBarLineScatterCandleBubbleDataSet dataSet) {
float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX()));
float low = chart.getLowestVisibleX();
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BubbleChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BubbleChartRenderer.java
index 6ff540c..458a46f 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BubbleChartRenderer.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/BubbleChartRenderer.java
@@ -52,7 +52,7 @@
for (int i = 0; i < setCount; i++) {
set = dataSets.get(i);
- if (set.isVisible() && set.getEntryCount() > 0)
+ if (set.isVisible())
drawDataSet(c, set);
}
}
@@ -133,7 +133,7 @@
IBubbleDataSet dataSet = dataSets.get(i);
- if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)
+ if (!shouldDrawValues(dataSet))
continue;
// apply the text-styling defined by the DataSet
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/CandleStickChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/CandleStickChartRenderer.java
index 2aa1148..734b430 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/CandleStickChartRenderer.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/CandleStickChartRenderer.java
@@ -50,7 +50,7 @@
for (int i = 0; i < setCount; i++) {
set = dataSets.get(i);
- if (set.isVisible() && set.getEntryCount() > 0)
+ if (set.isVisible())
drawDataSet(c, set);
}
}
@@ -266,7 +266,7 @@
ICandleDataSet dataSet = dataSets.get(i);
- if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)
+ if (!shouldDrawValues(dataSet))
continue;
// apply the text-styling defined by the DataSet
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.java
index 66f3e96..2162a28 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/HorizontalBarChartRenderer.java
@@ -116,7 +116,7 @@
IBarDataSet dataSet = dataSets.get(i);
- if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)
+ if (!shouldDrawValues(dataSet))
continue;
boolean isInverted = mChart.isInverted(dataSet.getAxisDependency());
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java
index aac9440..48c7a4b 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java
@@ -94,7 +94,7 @@
for (int i = 0; i < setCount; i++) {
set = lineData.getDataSets().get(i);
- if (set.isVisible() && set.getEntryCount() > 0)
+ if (set.isVisible())
drawDataSet(c, set);
}
@@ -519,7 +519,7 @@
ILineDataSet dataSet = dataSets.get(i);
- if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)
+ if (!shouldDrawValues(dataSet))
continue;
// apply the text-styling defined by the DataSet
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/RadarChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/RadarChartRenderer.java
index c346c6f..4d0a8d9 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/RadarChartRenderer.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/RadarChartRenderer.java
@@ -5,7 +5,6 @@
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
-import android.graphics.PointF;
import android.graphics.drawable.Drawable;
import com.github.mikephil.charting.animation.ChartAnimator;
@@ -70,7 +69,7 @@
for(int i = 0 ; i < setCount ; i++){
set = dataSets.get(i);
- if (set.isVisible() && set.getEntryCount() > 0) {
+ if (set.isVisible()) {
drawDataSet(c, set, mostEntries);
}
}
@@ -174,7 +173,7 @@
IRadarDataSet dataSet = mChart.getData().getDataSetByIndex(i);
- if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)
+ if (!shouldDrawValues(dataSet))
continue;
// apply the text-styling defined by the DataSet
diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/ScatterChartRenderer.java b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/ScatterChartRenderer.java
index 1d45c49..484bcba 100644
--- a/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/ScatterChartRenderer.java
+++ b/MPChartLib/src/main/java/com/github/mikephil/charting/renderer/ScatterChartRenderer.java
@@ -94,7 +94,7 @@
IScatterDataSet dataSet = dataSets.get(i);
- if (!dataSet.isDrawValuesEnabled() || dataSet.getEntryCount() == 0)
+ if (!shouldDrawValues(dataSet))
continue;
// apply the text-styling defined by the DataSet