Skip to content

Commit bef5b08

Browse files
committed
Merge pull request PhilJay#818 from danielgindi/fix-inf-in-matrix
Fixed a crash after matrix transformation when only one bar is visible
2 parents 31419f0 + 3a9ad3d commit bef5b08

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎MPChartLib/src/com/github/mikephil/charting/data/ChartData.java‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public void calcMinMax(int start, int end) {
203203
mLastEnd = end;
204204

205205
mYMin = Float.MAX_VALUE;
206-
mYMax = Float.MIN_VALUE;
206+
mYMax = -Float.MIN_VALUE;
207207

208208
for (int i = 0; i < mDataSets.size(); i++) {
209209

@@ -216,6 +216,11 @@ public void calcMinMax(int start, int end) {
216216
mYMax = mDataSets.get(i).getYMax();
217217
}
218218

219+
if (mYMin == Float.MAX_VALUE) {
220+
mYMin = 0.f;
221+
mYMax = 0.f;
222+
}
223+
219224
// left axis
220225
T firstLeft = getFirstLeft();
221226

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected void calcMinMax(int start, int end) {
123123
mLastEnd = endValue;
124124

125125
mYMin = Float.MAX_VALUE;
126-
mYMax = Float.MIN_VALUE;
126+
mYMax = -Float.MIN_VALUE;
127127

128128
for (int i = start; i <= endValue; i++) {
129129

@@ -138,6 +138,11 @@ protected void calcMinMax(int start, int end) {
138138
mYMax = e.getVal();
139139
}
140140
}
141+
142+
if (mYMin == Float.MAX_VALUE) {
143+
mYMin = 0.f;
144+
mYMax = 0.f;
145+
}
141146
}
142147

143148
/**

0 commit comments

Comments
 (0)