diff --git a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.java b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.java index 5cf49ea9d1..1204f78288 100644 --- a/MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.java +++ b/MPChartLib/src/main/java/com/github/mikephil/charting/charts/Chart.java @@ -791,10 +791,14 @@ protected void drawMarkers(Canvas canvas) { IDataSet set = mData.getDataSetByIndex(highlight.getDataSetIndex()); Entry e = mData.getEntryForHighlight(mIndicesToHighlight[i]); + + // make sure entry not null before using it + if (e == null) + continue; + int entryIndex = set.getEntryIndex(e); - // make sure entry not null - if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) + if (entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) continue; float[] pos = getMarkerPosition(highlight);