@@ -7,30 +7,30 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
7
7
/**
8
8
* maximum y-value in the value array across all axes
9
9
*/
10
- mYMax = - Number . MAX_VALUE ;
10
+ mYMax = - Infinity ;
11
11
12
12
/**
13
13
* the minimum y-value in the value array across all axes
14
14
*/
15
- mYMin = Number . MAX_VALUE ;
15
+ mYMin = Infinity ;
16
16
17
17
/**
18
18
* maximum x-value in the value array
19
19
*/
20
- mXMax = - Number . MAX_VALUE ;
20
+ mXMax = - Infinity ;
21
21
22
22
/**
23
23
* minimum x-value in the value array
24
24
*/
25
- mXMin = Number . MAX_VALUE ;
25
+ mXMin = Infinity ;
26
26
27
- mLeftAxisMax = - Number . MAX_VALUE ;
27
+ mLeftAxisMax = - Infinity ;
28
28
29
- mLeftAxisMin = Number . MAX_VALUE ;
29
+ mLeftAxisMin = Infinity ;
30
30
31
- mRightAxisMax = - Number . MAX_VALUE ;
31
+ mRightAxisMax = - Infinity ;
32
32
33
- mRightAxisMin = Number . MAX_VALUE ;
33
+ mRightAxisMin = Infinity ;
34
34
35
35
/**
36
36
* array that holds all DataSets the ChartData object represents
@@ -112,10 +112,10 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
112
112
protected calcMinMax ( ) {
113
113
if ( this . mDataSets == null ) return ;
114
114
115
- this . mYMax = - Number . MAX_VALUE ;
116
- this . mYMin = Number . MAX_VALUE ;
117
- this . mXMax = - Number . MAX_VALUE ;
118
- this . mXMin = Number . MAX_VALUE ;
115
+ this . mYMax = - Infinity ;
116
+ this . mYMin = Infinity ;
117
+ this . mXMax = - Infinity ;
118
+ this . mXMin = Infinity ;
119
119
120
120
const visibleDatasets = this . getVisibleDataSets ( ) ;
121
121
@@ -125,10 +125,10 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
125
125
}
126
126
}
127
127
128
- this . mLeftAxisMax = - Number . MAX_VALUE ;
129
- this . mLeftAxisMin = Number . MAX_VALUE ;
130
- this . mRightAxisMax = - Number . MAX_VALUE ;
131
- this . mRightAxisMin = Number . MAX_VALUE ;
128
+ this . mLeftAxisMax = - Infinity ;
129
+ this . mLeftAxisMin = Infinity ;
130
+ this . mRightAxisMax = - Infinity ;
131
+ this . mRightAxisMin = Infinity ;
132
132
133
133
// left axis
134
134
const firstLeft = this . getFirstLeft ( visibleDatasets ) ;
@@ -186,11 +186,17 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
186
186
return this . mYMin ;
187
187
}
188
188
if ( axis == AxisDependency . LEFT ) {
189
- if ( this . mLeftAxisMin == Number . MAX_VALUE ) {
189
+ if ( ! Number . isFinite ( this . mLeftAxisMin ) ) {
190
+ if ( ! Number . isFinite ( this . mRightAxisMin ) ) {
191
+ return 0 ;
192
+ }
190
193
return this . mRightAxisMin ;
191
194
} else return this . mLeftAxisMin ;
192
195
} else {
193
- if ( this . mRightAxisMin == Number . MAX_VALUE ) {
196
+ if ( ! Number . isFinite ( this . mRightAxisMin ) ) {
197
+ if ( ! Number . isFinite ( this . mLeftAxisMin ) ) {
198
+ return 0 ;
199
+ }
194
200
return this . mLeftAxisMin ;
195
201
} else return this . mRightAxisMin ;
196
202
}
@@ -207,11 +213,17 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
207
213
return this . mYMax ;
208
214
}
209
215
if ( axis == AxisDependency . LEFT ) {
210
- if ( this . mLeftAxisMax == - Number . MAX_VALUE ) {
216
+ if ( ! Number . isFinite ( this . mLeftAxisMax ) ) {
217
+ if ( ! Number . isFinite ( this . mRightAxisMax ) ) {
218
+ return 0 ;
219
+ }
211
220
return this . mRightAxisMax ;
212
221
} else return this . mLeftAxisMax ;
213
222
} else {
214
- if ( this . mRightAxisMax == - Number . MAX_VALUE ) {
223
+ if ( ! Number . isFinite ( this . mRightAxisMax ) ) {
224
+ if ( ! Number . isFinite ( this . mLeftAxisMax ) ) {
225
+ return 0 ;
226
+ }
215
227
return this . mLeftAxisMax ;
216
228
} else return this . mRightAxisMax ;
217
229
}
@@ -260,9 +272,9 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
260
272
*/
261
273
protected getDataSetIndexByLabel ( dataSets , label , ignorecase ) {
262
274
if ( ignorecase ) {
263
- for ( let i = 0 ; i < dataSets . length ; i ++ ) if ( label . equalsIgnoreCase ( dataSets . get ( i ) . getLabel ( ) ) ) return i ;
275
+ for ( let i = 0 ; i < dataSets . length ; i ++ ) if ( label . equalsIgnoreCase ( dataSets [ i ] . getLabel ( ) ) ) return i ;
264
276
} else {
265
- for ( let i = 0 ; i < dataSets . length ; i ++ ) if ( label . equals ( dataSets . get ( i ) . getLabel ( ) ) ) return i ;
277
+ for ( let i = 0 ; i < dataSets . length ; i ++ ) if ( label . equals ( dataSets [ i ] . getLabel ( ) ) ) return i ;
266
278
}
267
279
268
280
return - 1 ;
0 commit comments