Skip to content

Commit 6c9fcc7

Browse files
authored
Merge pull request #126 from oliverClimbs/master
Added missing null checks to drawValues()
2 parents 4cca9f3 + 8cec0ad commit 6c9fcc7

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/renderer/LineChartRenderer.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -595,22 +595,24 @@ public void drawValues(Canvas c) {
595595

596596
Entry entry = dataSet.getEntryForIndex(j / 2 + mXBounds.min);
597597

598-
if (dataSet.isDrawValuesEnabled()) {
599-
drawValue(c, dataSet.getValueFormatter(), entry.getY(), entry, i, x,
600-
y - valOffset, dataSet.getValueTextColor(j / 2));
601-
}
602-
603-
if (entry.getIcon() != null && dataSet.isDrawIconsEnabled()) {
604-
605-
Drawable icon = entry.getIcon();
606-
607-
Utils.drawImage(
608-
c,
609-
icon,
610-
(int)(x + iconsOffset.x),
611-
(int)(y + iconsOffset.y),
612-
icon.getIntrinsicWidth(),
613-
icon.getIntrinsicHeight());
598+
if (entry != null) {
599+
if (dataSet.isDrawValuesEnabled()) {
600+
drawValue(c, dataSet.getValueFormatter(), entry.getY(), entry, i, x,
601+
y - valOffset, dataSet.getValueTextColor(j / 2));
602+
}
603+
604+
if (entry.getIcon() != null && dataSet.isDrawIconsEnabled()) {
605+
606+
Drawable icon = entry.getIcon();
607+
608+
Utils.drawImage(
609+
c,
610+
icon,
611+
(int)(x + iconsOffset.x),
612+
(int)(y + iconsOffset.y),
613+
icon.getIntrinsicWidth(),
614+
icon.getIntrinsicHeight());
615+
}
614616
}
615617
}
616618

0 commit comments

Comments
 (0)