Skip to content

Commit 200fba7

Browse files
committed
Removed ambiguity of mDataNotSet
We can just check for mData being null, knowing that this is the situation defined as "no data"
1 parent b19a42e commit 200fba7

File tree

7 files changed

+12
-23
lines changed

7 files changed

+12
-23
lines changed

MPChartLib/src/com/github/mikephil/charting/charts/BarChart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ protected void calcMinMax() {
9292
@Override
9393
public Highlight getHighlightByTouchPoint(float x, float y) {
9494

95-
if (mDataNotSet || mData == null) {
95+
if (mData == null) {
9696
Log.e(LOG_TAG, "Can't select by touch. No data set.");
9797
return null;
9898
} else

MPChartLib/src/com/github/mikephil/charting/charts/BarLineChartBase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ protected void init() {
188188
protected void onDraw(Canvas canvas) {
189189
super.onDraw(canvas);
190190

191-
if (mDataNotSet)
191+
if (mData == null)
192192
return;
193193

194194
long starttime = System.currentTimeMillis();
@@ -315,7 +315,7 @@ protected void prepareOffsetMatrix() {
315315
@Override
316316
public void notifyDataSetChanged() {
317317

318-
if (mDataNotSet) {
318+
if (mData == null) {
319319
if (mLogEnabled)
320320
Log.i(LOG_TAG, "Preparing... DATA NOT SET.");
321321
return;
@@ -653,7 +653,7 @@ public Transformer getTransformer(AxisDependency which) {
653653
public boolean onTouchEvent(MotionEvent event) {
654654
super.onTouchEvent(event);
655655

656-
if (mChartTouchListener == null || mDataNotSet)
656+
if (mChartTouchListener == null || mData == null)
657657
return false;
658658

659659
// check if touch gestures are enabled
@@ -1154,7 +1154,7 @@ public void setMinOffset(float minOffset) {
11541154
*/
11551155
public Highlight getHighlightByTouchPoint(float x, float y) {
11561156

1157-
if (mDataNotSet || mData == null) {
1157+
if (mData == null) {
11581158
Log.e(LOG_TAG, "Can't select by touch. No data set.");
11591159
return null;
11601160
} else

MPChartLib/src/com/github/mikephil/charting/charts/Chart.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,6 @@ public abstract class Chart<T extends ChartData<? extends DataSet<? extends Entr
116116
*/
117117
protected String mDescription = "Description";
118118

119-
/**
120-
* flag that indicates if the chart has been fed with data yet
121-
*/
122-
protected boolean mDataNotSet = true;
123-
124119
/**
125120
* the number of x-values the chart displays
126121
*/
@@ -309,7 +304,6 @@ public void setData(T data) {
309304
}
310305

311306
// LET THE CHART KNOW THERE IS DATA
312-
mDataNotSet = false;
313307
mOffsetsCalculated = false;
314308
mData = data;
315309

@@ -334,7 +328,6 @@ public void setData(T data) {
334328
*/
335329
public void clear() {
336330
mData = null;
337-
mDataNotSet = true;
338331
mIndicesToHighlight = null;
339332
invalidate();
340333
}
@@ -420,11 +413,7 @@ protected void calculateFormatter(float min, float max) {
420413
protected void onDraw(Canvas canvas) {
421414
// super.onDraw(canvas);
422415

423-
if (mDataNotSet || mData == null || mData.getYValCount() <= 0) { // check
424-
// if
425-
// there
426-
// is
427-
// data
416+
if (mData == null) {
428417

429418
// if no data, inform the user
430419
canvas.drawText(mNoDataText, getWidth() / 2, getHeight() / 2, mInfoPaint);

MPChartLib/src/com/github/mikephil/charting/charts/HorizontalBarChart.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public PointF getPosition(Entry e, AxisDependency axis) {
220220
@Override
221221
public Highlight getHighlightByTouchPoint(float x, float y) {
222222

223-
if (mDataNotSet || mData == null) {
223+
if (mData == null) {
224224
Log.e(LOG_TAG, "Can't select by touch. No data set.");
225225
return null;
226226
} else

MPChartLib/src/com/github/mikephil/charting/charts/PieChart.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected void init() {
113113
protected void onDraw(Canvas canvas) {
114114
super.onDraw(canvas);
115115

116-
if (mDataNotSet)
116+
if (mData == null)
117117
return;
118118

119119
mRenderer.drawData(canvas);
@@ -137,7 +137,7 @@ public void calculateOffsets() {
137137
super.calculateOffsets();
138138

139139
// prevent nullpointer when no data set
140-
if (mDataNotSet)
140+
if (mData == null)
141141
return;
142142

143143
float diameter = getDiameter();

MPChartLib/src/com/github/mikephil/charting/charts/PieRadarChartBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void computeScroll() {
8787

8888
@Override
8989
public void notifyDataSetChanged() {
90-
if (mDataNotSet)
90+
if (mData == null)
9191
return;
9292

9393
calcMinMax();

MPChartLib/src/com/github/mikephil/charting/charts/RadarChart.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected float[] getMarkerPosition(Entry e, Highlight highlight) {
161161

162162
@Override
163163
public void notifyDataSetChanged() {
164-
if (mDataNotSet)
164+
if (mData == null)
165165
return;
166166

167167
calcMinMax();
@@ -183,7 +183,7 @@ public void notifyDataSetChanged() {
183183
protected void onDraw(Canvas canvas) {
184184
super.onDraw(canvas);
185185

186-
if (mDataNotSet)
186+
if (mData == null)
187187
return;
188188

189189
mXAxisRenderer.renderAxisLabels(canvas);

0 commit comments

Comments
 (0)