Skip to content

Commit 67f82f1

Browse files
committed
Renamed values -> entries for consistency
ChartsOrg/Charts#3847
1 parent a8542c3 commit 67f82f1

File tree

9 files changed

+82
-64
lines changed

9 files changed

+82
-64
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/data/BarDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public DataSet<BarEntry> copy() {
5555
List<BarEntry> yVals = new ArrayList<BarEntry>();
5656
yVals.clear();
5757

58-
for (int i = 0; i < mValues.size(); i++) {
59-
yVals.add(mValues.get(i).copy());
58+
for (int i = 0; i < mEntries.size(); i++) {
59+
yVals.add(mEntries.get(i).copy());
6060
}
6161

6262
BarDataSet copied = new BarDataSet(yVals, getLabel());

MPChartLib/src/main/java/com/github/mikephil/charting/data/BubbleDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public DataSet<BubbleEntry> copy() {
4444

4545
List<BubbleEntry> yVals = new ArrayList<BubbleEntry>();
4646

47-
for (int i = 0; i < mValues.size(); i++) {
48-
yVals.add(mValues.get(i).copy());
47+
for (int i = 0; i < mEntries.size(); i++) {
48+
yVals.add(mEntries.get(i).copy());
4949
}
5050

5151
BubbleDataSet copied = new BubbleDataSet(yVals, getLabel());

MPChartLib/src/main/java/com/github/mikephil/charting/data/CandleDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public DataSet<CandleEntry> copy() {
8383
List<CandleEntry> yVals = new ArrayList<CandleEntry>();
8484
yVals.clear();
8585

86-
for (int i = 0; i < mValues.size(); i++) {
87-
yVals.add(mValues.get(i).copy());
86+
for (int i = 0; i < mEntries.size(); i++) {
87+
yVals.add(mEntries.get(i).copy());
8888
}
8989

9090
CandleDataSet copied = new CandleDataSet(yVals, getLabel());

MPChartLib/src/main/java/com/github/mikephil/charting/data/DataSet.java

Lines changed: 68 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public abstract class DataSet<T extends Entry> extends BaseDataSet<T> {
1717
/**
1818
* the entries that this DataSet represents / holds together
1919
*/
20-
protected List<T> mValues = null;
20+
protected List<T> mEntries;
2121

2222
/**
2323
* maximum y-value in the value array
@@ -45,15 +45,15 @@ public abstract class DataSet<T extends Entry> extends BaseDataSet<T> {
4545
* label that describes the DataSet can be specified. The label can also be
4646
* used to retrieve the DataSet from a ChartData object.
4747
*
48-
* @param values
48+
* @param entries
4949
* @param label
5050
*/
51-
public DataSet(List<T> values, String label) {
51+
public DataSet(List<T> entries, String label) {
5252
super(label);
53-
this.mValues = values;
53+
this.mEntries = entries;
5454

55-
if (mValues == null)
56-
mValues = new ArrayList<T>();
55+
if (mEntries == null)
56+
mEntries = new ArrayList<T>();
5757

5858
calcMinMax();
5959
}
@@ -66,10 +66,10 @@ public void calcMinMax() {
6666
mXMax = -Float.MAX_VALUE;
6767
mXMin = Float.MAX_VALUE;
6868

69-
if (mValues == null || mValues.isEmpty())
69+
if (mEntries == null || mEntries.isEmpty())
7070
return;
7171

72-
for (T e : mValues) {
72+
for (T e : mEntries) {
7373
calcMinMax(e);
7474
}
7575
}
@@ -79,7 +79,7 @@ public void calcMinMaxY(float fromX, float toX) {
7979
mYMax = -Float.MAX_VALUE;
8080
mYMin = Float.MAX_VALUE;
8181

82-
if (mValues == null || mValues.isEmpty())
82+
if (mEntries == null || mEntries.isEmpty())
8383
return;
8484

8585
int indexFrom = getEntryIndex(fromX, Float.NaN, Rounding.DOWN);
@@ -90,7 +90,7 @@ public void calcMinMaxY(float fromX, float toX) {
9090
for (int i = indexFrom; i <= indexTo; i++) {
9191

9292
// only recalculate y
93-
calcMinMaxY(mValues.get(i));
93+
calcMinMaxY(mEntries.get(i));
9494
}
9595
}
9696

@@ -129,25 +129,47 @@ protected void calcMinMaxY(T e) {
129129

130130
@Override
131131
public int getEntryCount() {
132-
return mValues.size();
132+
return mEntries.size();
133133
}
134134

135135
/**
136-
* Returns the array of entries that this DataSet represents.
136+
* This method is deprecated.
137+
* Use getEntries() instead.
137138
*
138139
* @return
139140
*/
141+
@Deprecated
140142
public List<T> getValues() {
141-
return mValues;
143+
return mEntries;
142144
}
143145

144146
/**
145-
* Sets the array of entries that this DataSet represents, and calls notifyDataSetChanged()
147+
* Returns the array of entries that this DataSet represents.
146148
*
147149
* @return
148150
*/
151+
public List<T> getEntries() {
152+
return mEntries;
153+
}
154+
155+
/**
156+
* This method is deprecated.
157+
* Use setEntries(...) instead.
158+
*
159+
* @param values
160+
*/
161+
@Deprecated
149162
public void setValues(List<T> values) {
150-
mValues = values;
163+
setEntries(values);
164+
}
165+
166+
/**
167+
* Sets the array of entries that this DataSet represents, and calls notifyDataSetChanged()
168+
*
169+
* @return
170+
*/
171+
public void setEntries(List<T> entries) {
172+
mEntries = entries;
151173
notifyDataSetChanged();
152174
}
153175

@@ -162,8 +184,8 @@ public void setValues(List<T> values) {
162184
public String toString() {
163185
StringBuffer buffer = new StringBuffer();
164186
buffer.append(toSimpleString());
165-
for (int i = 0; i < mValues.size(); i++) {
166-
buffer.append(mValues.get(i).toString() + " ");
187+
for (int i = 0; i < mEntries.size(); i++) {
188+
buffer.append(mEntries.get(i).toString() + " ");
167189
}
168190
return buffer.toString();
169191
}
@@ -176,7 +198,7 @@ public String toString() {
176198
*/
177199
public String toSimpleString() {
178200
StringBuffer buffer = new StringBuffer();
179-
buffer.append("DataSet, label: " + (getLabel() == null ? "" : getLabel()) + ", entries: " + mValues.size() +
201+
buffer.append("DataSet, label: " + (getLabel() == null ? "" : getLabel()) + ", entries: " + mEntries.size() +
180202
"\n");
181203
return buffer.toString();
182204
}
@@ -207,23 +229,23 @@ public void addEntryOrdered(T e) {
207229
if (e == null)
208230
return;
209231

210-
if (mValues == null) {
211-
mValues = new ArrayList<T>();
232+
if (mEntries == null) {
233+
mEntries = new ArrayList<T>();
212234
}
213235

214236
calcMinMax(e);
215237

216-
if (mValues.size() > 0 && mValues.get(mValues.size() - 1).getX() > e.getX()) {
238+
if (mEntries.size() > 0 && mEntries.get(mEntries.size() - 1).getX() > e.getX()) {
217239
int closestIndex = getEntryIndex(e.getX(), e.getY(), Rounding.UP);
218-
mValues.add(closestIndex, e);
240+
mEntries.add(closestIndex, e);
219241
} else {
220-
mValues.add(e);
242+
mEntries.add(e);
221243
}
222244
}
223245

224246
@Override
225247
public void clear() {
226-
mValues.clear();
248+
mEntries.clear();
227249
notifyDataSetChanged();
228250
}
229251

@@ -233,9 +255,9 @@ public boolean addEntry(T e) {
233255
if (e == null)
234256
return false;
235257

236-
List<T> values = getValues();
258+
List<T> values = getEntries();
237259
if (values == null) {
238-
values = new ArrayList<T>();
260+
values = new ArrayList<>();
239261
}
240262

241263
calcMinMax(e);
@@ -250,11 +272,11 @@ public boolean removeEntry(T e) {
250272
if (e == null)
251273
return false;
252274

253-
if (mValues == null)
275+
if (mEntries == null)
254276
return false;
255277

256278
// remove the entry
257-
boolean removed = mValues.remove(e);
279+
boolean removed = mEntries.remove(e);
258280

259281
if (removed) {
260282
calcMinMax();
@@ -265,15 +287,15 @@ public boolean removeEntry(T e) {
265287

266288
@Override
267289
public int getEntryIndex(Entry e) {
268-
return mValues.indexOf(e);
290+
return mEntries.indexOf(e);
269291
}
270292

271293
@Override
272294
public T getEntryForXValue(float xValue, float closestToY, Rounding rounding) {
273295

274296
int index = getEntryIndex(xValue, closestToY, rounding);
275297
if (index > -1)
276-
return mValues.get(index);
298+
return mEntries.get(index);
277299
return null;
278300
}
279301

@@ -284,24 +306,24 @@ public T getEntryForXValue(float xValue, float closestToY) {
284306

285307
@Override
286308
public T getEntryForIndex(int index) {
287-
return mValues.get(index);
309+
return mEntries.get(index);
288310
}
289311

290312
@Override
291313
public int getEntryIndex(float xValue, float closestToY, Rounding rounding) {
292314

293-
if (mValues == null || mValues.isEmpty())
315+
if (mEntries == null || mEntries.isEmpty())
294316
return -1;
295317

296318
int low = 0;
297-
int high = mValues.size() - 1;
319+
int high = mEntries.size() - 1;
298320
int closest = high;
299321

300322
while (low < high) {
301323
int m = (low + high) / 2;
302324

303-
final float d1 = mValues.get(m).getX() - xValue,
304-
d2 = mValues.get(m + 1).getX() - xValue,
325+
final float d1 = mEntries.get(m).getX() - xValue,
326+
d2 = mEntries.get(m + 1).getX() - xValue,
305327
ad1 = Math.abs(d1), ad2 = Math.abs(d2);
306328

307329
if (ad2 < ad1) {
@@ -328,10 +350,10 @@ public int getEntryIndex(float xValue, float closestToY, Rounding rounding) {
328350
}
329351

330352
if (closest != -1) {
331-
float closestXValue = mValues.get(closest).getX();
353+
float closestXValue = mEntries.get(closest).getX();
332354
if (rounding == Rounding.UP) {
333355
// If rounding up, and found x-value is lower than specified x, and we can go upper...
334-
if (closestXValue < xValue && closest < mValues.size() - 1) {
356+
if (closestXValue < xValue && closest < mEntries.size() - 1) {
335357
++closest;
336358
}
337359
} else if (rounding == Rounding.DOWN) {
@@ -343,18 +365,18 @@ public int getEntryIndex(float xValue, float closestToY, Rounding rounding) {
343365

344366
// Search by closest to y-value
345367
if (!Float.isNaN(closestToY)) {
346-
while (closest > 0 && mValues.get(closest - 1).getX() == closestXValue)
368+
while (closest > 0 && mEntries.get(closest - 1).getX() == closestXValue)
347369
closest -= 1;
348370

349-
float closestYValue = mValues.get(closest).getY();
371+
float closestYValue = mEntries.get(closest).getY();
350372
int closestYIndex = closest;
351373

352374
while (true) {
353375
closest += 1;
354-
if (closest >= mValues.size())
376+
if (closest >= mEntries.size())
355377
break;
356378

357-
final Entry value = mValues.get(closest);
379+
final Entry value = mEntries.get(closest);
358380

359381
if (value.getX() != closestXValue)
360382
break;
@@ -378,22 +400,22 @@ public List<T> getEntriesForXValue(float xValue) {
378400
List<T> entries = new ArrayList<T>();
379401

380402
int low = 0;
381-
int high = mValues.size() - 1;
403+
int high = mEntries.size() - 1;
382404

383405
while (low <= high) {
384406
int m = (high + low) / 2;
385-
T entry = mValues.get(m);
407+
T entry = mEntries.get(m);
386408

387409
// if we have a match
388410
if (xValue == entry.getX()) {
389-
while (m > 0 && mValues.get(m - 1).getX() == xValue)
411+
while (m > 0 && mEntries.get(m - 1).getX() == xValue)
390412
m--;
391413

392-
high = mValues.size();
414+
high = mEntries.size();
393415

394416
// loop over all "equal" entries
395417
for (; m < high; m++) {
396-
entry = mValues.get(m);
418+
entry = mEntries.get(m);
397419
if (entry.getX() == xValue) {
398420
entries.add(entry);
399421
} else {

MPChartLib/src/main/java/com/github/mikephil/charting/data/LineDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public DataSet<Entry> copy() {
8787

8888
List<Entry> yVals = new ArrayList<Entry>();
8989

90-
for (int i = 0; i < mValues.size(); i++) {
91-
yVals.add(mValues.get(i).copy());
90+
for (int i = 0; i < mEntries.size(); i++) {
91+
yVals.add(mEntries.get(i).copy());
9292
}
9393

9494
LineDataSet copied = new LineDataSet(yVals, getLabel());

MPChartLib/src/main/java/com/github/mikephil/charting/data/PieDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public DataSet<PieEntry> copy() {
3838

3939
List<PieEntry> yVals = new ArrayList<>();
4040

41-
for (int i = 0; i < mValues.size(); i++) {
42-
yVals.add(mValues.get(i).copy());
41+
for (int i = 0; i < mEntries.size(); i++) {
42+
yVals.add(mEntries.get(i).copy());
4343
}
4444

4545
PieDataSet copied = new PieDataSet(yVals, getLabel());

MPChartLib/src/main/java/com/github/mikephil/charting/data/RadarDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ public DataSet<RadarEntry> copy() {
118118

119119
List<RadarEntry> yVals = new ArrayList<RadarEntry>();
120120

121-
for (int i = 0; i < mValues.size(); i++) {
122-
yVals.add(mValues.get(i).copy());
121+
for (int i = 0; i < mEntries.size(); i++) {
122+
yVals.add(mEntries.get(i).copy());
123123
}
124124

125125
RadarDataSet copied = new RadarDataSet(yVals, getLabel());

MPChartLib/src/main/java/com/github/mikephil/charting/data/ScatterDataSet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public DataSet<Entry> copy() {
5050

5151
List<Entry> yVals = new ArrayList<Entry>();
5252

53-
for (int i = 0; i < mValues.size(); i++) {
54-
yVals.add(mValues.get(i).copy());
53+
for (int i = 0; i < mEntries.size(); i++) {
54+
yVals.add(mEntries.get(i).copy());
5555
}
5656

5757
ScatterDataSet copied = new ScatterDataSet(yVals, getLabel());

MPChartLib/src/main/java/com/github/mikephil/charting/formatter/IndexAxisValueFormatter.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22
package com.github.mikephil.charting.formatter;
33

44
import com.github.mikephil.charting.components.AxisBase;
5-
import com.github.mikephil.charting.data.Entry;
6-
import com.github.mikephil.charting.utils.ViewPortHandler;
75

8-
import java.text.DecimalFormat;
9-
import java.util.Arrays;
106
import java.util.Collection;
117

128
/**

0 commit comments

Comments
 (0)