Skip to content

Commit 0aeddb0

Browse files
committed
Fix issue causing ANR for empty charts
1 parent e9459fb commit 0aeddb0

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,15 @@ protected void computeAxisValues(float min, float max) {
154154
int labelCount = mAxis.getLabelCount();
155155
double range = Math.abs(yMax - yMin);
156156

157-
if (labelCount == 0 || range <= 0) {
157+
if (labelCount == 0 || range <= 0 || Double.isInfinite(range)) {
158158
mAxis.mEntries = new float[]{};
159+
mAxis.mCenteredEntries = new float[]{};
159160
mAxis.mEntryCount = 0;
160161
return;
161162
}
162163

163164
// Find out how much spacing (in y value space) between axis values
164165
double rawInterval = range / labelCount;
165-
if (Double.isInfinite(rawInterval))
166-
{
167-
rawInterval = range > 0.0 && !Double.isInfinite(range) ? range : 1.0;
168-
}
169166
double interval = Utils.roundToNextSignificant(rawInterval);
170167

171168
// If granularity is enabled, then do not allow the interval to go below specified granularity.

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,15 @@ protected void computeAxisValues(float min, float max) {
3232
int labelCount = mAxis.getLabelCount();
3333
double range = Math.abs(yMax - yMin);
3434

35-
if (labelCount == 0 || range <= 0) {
35+
if (labelCount == 0 || range <= 0 || Double.isInfinite(range)) {
3636
mAxis.mEntries = new float[]{};
37+
mAxis.mCenteredEntries = new float[]{};
3738
mAxis.mEntryCount = 0;
3839
return;
3940
}
4041

4142
// Find out how much spacing (in y value space) between axis values
4243
double rawInterval = range / labelCount;
43-
if (Double.isInfinite(rawInterval))
44-
{
45-
rawInterval = range > 0.0 && !Double.isInfinite(range) ? range : 1.0;
46-
}
4744
double interval = Utils.roundToNextSignificant(rawInterval);
4845

4946
// If granularity is enabled, then do not allow the interval to go below specified granularity.

0 commit comments

Comments
 (0)