Remove y-value-sum from DataSets as it is not needed
diff --git a/MPChartLib/src/com/github/mikephil/charting/data/ChartData.java b/MPChartLib/src/com/github/mikephil/charting/data/ChartData.java
index a24f890..e7063b0 100644
--- a/MPChartLib/src/com/github/mikephil/charting/data/ChartData.java
+++ b/MPChartLib/src/com/github/mikephil/charting/data/ChartData.java
@@ -41,11 +41,6 @@
protected float mRightAxisMin = 0.0f;
/**
- * the total sum of all y-values
- */
- private float mYValueSum = 0f;
-
- /**
* total number of y-values across all DataSet objects
*/
private int mYValCount = 0;
@@ -154,7 +149,6 @@
checkLegal();
calcMinMax(mLastStart, mLastEnd);
- calcYValueSum();
calcYValueCount();
calcXValAverageLength();
@@ -228,13 +222,14 @@
for (int i = 0; i < mDataSets.size(); i++) {
- mDataSets.get(i).calcMinMax(start, end);
+ T set = mDataSets.get(i);
+ set.calcMinMax(set.getYVals(), start, end);
- if (mDataSets.get(i).getYMin() < mYMin)
- mYMin = mDataSets.get(i).getYMin();
+ if (set.getYMin() < mYMin)
+ mYMin = set.getYMin();
- if (mDataSets.get(i).getYMax() > mYMax)
- mYMax = mDataSets.get(i).getYMax();
+ if (set.getYMax() > mYMax)
+ mYMax = set.getYMax();
}
if (mYMin == Float.MAX_VALUE) {
@@ -286,21 +281,6 @@
}
/**
- * calculates the sum of all y-values in all datasets
- */
- protected void calcYValueSum() {
-
- mYValueSum = 0;
-
- if (mDataSets == null)
- return;
-
- for (int i = 0; i < mDataSets.size(); i++) {
- mYValueSum += Math.abs(mDataSets.get(i).getYValueSum());
- }
- }
-
- /**
* Calculates the total number of y-values across all DataSets the ChartData
* represents.
*
@@ -336,15 +316,6 @@
}
/**
- * Returns the average value across all entries in this Data object
- * (all entries from the DataSets this data object holds)
- * @return
- */
- public float getAverage() {
- return (float ) getYValueSum() / (float) getYValCount();
- }
-
- /**
* Returns the smallest y-value the data object contains.
*
* @return
@@ -398,16 +369,6 @@
return mXValAverageLength;
}
- /**
- * Returns the total y-value sum across all DataSet objects the this object
- * represents.
- *
- * @return
- */
- public float getYValueSum() {
- return mYValueSum;
- }
-
@Override
public int getYValCount() {
return mYValCount;
@@ -553,7 +514,6 @@
return;
mYValCount += d.getEntryCount();
- mYValueSum += d.getYValueSum();
if (mDataSets.size() <= 0) {
@@ -630,7 +590,6 @@
if (removed) {
mYValCount -= d.getEntryCount();
- mYValueSum -= d.getYValueSum();
calcMinMax(mLastStart, mLastEnd);
}
@@ -702,7 +661,6 @@
}
mYValCount += 1;
- mYValueSum += val;
handleEmptyAxis(getFirstLeft(), getFirstRight());
@@ -729,11 +687,7 @@
boolean removed = mDataSets.get(dataSetIndex).removeEntry(e.getXIndex());
if (removed) {
-
- float val = e.getVal();
-
mYValCount -= 1;
- mYValueSum -= val;
calcMinMax(mLastStart, mLastEnd);
}
diff --git a/MPChartLib/src/com/github/mikephil/charting/data/DataSet.java b/MPChartLib/src/com/github/mikephil/charting/data/DataSet.java
index 278f55c..c3d43ec 100644
--- a/MPChartLib/src/com/github/mikephil/charting/data/DataSet.java
+++ b/MPChartLib/src/com/github/mikephil/charting/data/DataSet.java
@@ -36,11 +36,6 @@
protected List<Integer> mColors = null;
/**
- * the total sum of all y-values
- */
- private float mYValueSum = 0f;
-
- /**
* label that describes the DataSet or the data the DataSet represents
*/
private String mLabel = "DataSet";
@@ -107,7 +102,6 @@
mColors.add(Color.rgb(140, 234, 255));
calcMinMax(mYVals, mLastStart, mLastEnd);
- calcYValueSum();
}
/**
@@ -115,21 +109,6 @@
*/
public void notifyDataSetChanged() {
calcMinMax(mYVals, mLastStart, mLastEnd);
- calcYValueSum();
- }
-
- /**
- * calculates the sum of all y-values
- */
- private void calcYValueSum() {
-
- mYValueSum = 0;
-
- for (int i = 0; i < mYVals.size(); i++) {
- Entry e = mYVals.get(i);
- if (e != null)
- mYValueSum += Math.abs(e.getVal());
- }
}
/**
@@ -260,11 +239,6 @@
}
@Override
- public float getYValueSum() {
- return mYValueSum;
- }
-
- @Override
public float getYMin() {
return mYMin;
}
@@ -430,8 +404,6 @@
mYMin = val;
}
- mYValueSum += val;
-
// add the entry
mYVals.add((T) e);
}
@@ -466,8 +438,6 @@
mYMin = val;
}
- mYValueSum += val;
-
if (mYVals.size() > 0 && mYVals.get(mYVals.size() - 1).getXIndex() > e.getXIndex()) {
int closestIndex = getEntryIndex(e.getXIndex());
if (mYVals.get(closestIndex).getXIndex() < e.getXIndex())
@@ -496,10 +466,6 @@
boolean removed = mYVals.remove(e);
if (removed) {
-
- float val = e.getVal();
- mYValueSum -= val;
-
calcMinMax(mYVals, mLastStart, mLastEnd);
}
@@ -531,10 +497,6 @@
boolean removed = entry != null;
if (removed) {
-
- float val = entry.getVal();
- mYValueSum -= val;
-
calcMinMax(mYVals, mLastStart, mLastEnd);
}
@@ -557,10 +519,6 @@
boolean removed = entry != null;
if (removed) {
-
- float val = entry.getVal();
- mYValueSum -= val;
-
calcMinMax(mYVals, mLastStart, mLastEnd);
}
diff --git a/MPChartLib/src/com/github/mikephil/charting/interfaces/datainterfaces/datasets/IDataSet.java b/MPChartLib/src/com/github/mikephil/charting/interfaces/datainterfaces/datasets/IDataSet.java
index ca57116..f1a881b 100644
--- a/MPChartLib/src/com/github/mikephil/charting/interfaces/datainterfaces/datasets/IDataSet.java
+++ b/MPChartLib/src/com/github/mikephil/charting/interfaces/datainterfaces/datasets/IDataSet.java
@@ -39,13 +39,6 @@
float getYMax();
/**
- * gets the sum of all y-values
- *
- * @return
- */
- float getYValueSum();
-
- /**
* returns the number of y-values this DataSet represents -> yvals.size()
*
* @return