@@ -117,8 +117,12 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
117
117
this . mXMax = - Number . MAX_VALUE ;
118
118
this . mXMin = Number . MAX_VALUE ;
119
119
120
- for ( let set of this . mDataSets ) {
121
- this . calcMinMaxForDataSet ( set ) ;
120
+ const visibleDatasets = this . mDataSets . filter ( s => s . isVisible ( ) ) ;
121
+
122
+ for ( let set of visibleDatasets ) {
123
+ if ( set . isVisible ( ) ) {
124
+ this . calcMinMaxForDataSet ( set ) ;
125
+ }
122
126
}
123
127
124
128
this . mLeftAxisMax = - Number . MAX_VALUE ;
@@ -127,13 +131,13 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
127
131
this . mRightAxisMin = Number . MAX_VALUE ;
128
132
129
133
// left axis
130
- const firstLeft = this . getFirstLeft ( this . mDataSets ) ;
134
+ const firstLeft = this . getFirstLeft ( visibleDatasets ) ;
131
135
132
136
if ( firstLeft != null ) {
133
137
this . mLeftAxisMax = firstLeft . getYMax ( ) ;
134
138
this . mLeftAxisMin = firstLeft . getYMin ( ) ;
135
139
136
- for ( let dataSet of this . mDataSets ) {
140
+ for ( let dataSet of visibleDatasets ) {
137
141
if ( dataSet . getAxisDependency ( ) == AxisDependency . LEFT ) {
138
142
if ( dataSet . getYMin ( ) < this . mLeftAxisMin ) this . mLeftAxisMin = dataSet . getYMin ( ) ;
139
143
@@ -143,13 +147,13 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
143
147
}
144
148
145
149
// right axis
146
- const firstRight = this . getFirstRight ( this . mDataSets ) ;
150
+ const firstRight = this . getFirstRight ( visibleDatasets ) ;
147
151
148
152
if ( firstRight != null ) {
149
153
this . mRightAxisMax = firstRight . getYMax ( ) ;
150
154
this . mRightAxisMin = firstRight . getYMin ( ) ;
151
155
152
- for ( let dataSet of this . mDataSets ) {
156
+ for ( let dataSet of visibleDatasets ) {
153
157
if ( dataSet . getAxisDependency ( ) == AxisDependency . RIGHT ) {
154
158
if ( dataSet . getYMin ( ) < this . mRightAxisMin ) this . mRightAxisMin = dataSet . getYMin ( ) ;
155
159
@@ -308,7 +312,7 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
308
312
else return this . mDataSets [ index ] ;
309
313
}
310
314
311
- public getDataSetByIndex ( index :number ) {
315
+ public getDataSetByIndex ( index : number ) {
312
316
if ( this . mDataSets == null || index < 0 || index >= this . mDataSets . length ) return null ;
313
317
314
318
return this . mDataSets [ index ] ;
@@ -321,8 +325,9 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
321
325
*/
322
326
public addDataSet ( d : T ) {
323
327
if ( d == null ) return ;
324
-
325
- this . calcMinMaxForDataSet ( d ) ;
328
+ if ( d . isVisible ( ) ) {
329
+ this . calcMinMaxForDataSet ( d ) ;
330
+ }
326
331
327
332
this . mDataSets . push ( d ) ;
328
333
}
@@ -376,7 +381,9 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
376
381
// add the entry to the dataset
377
382
if ( ! set . addEntry ( e ) ) return ;
378
383
379
- this . calcMinMaxForEntry ( set , e , set . getAxisDependency ( ) ) ;
384
+ if ( set . isVisible ( ) ) {
385
+ this . calcMinMaxForEntry ( set , e , set . getAxisDependency ( ) ) ;
386
+ }
380
387
} else {
381
388
console . error ( 'addEntry' , 'Cannot add Entry because dataSetIndex too high or too low.' ) ;
382
389
}
@@ -388,7 +395,7 @@ export abstract class ChartData<U extends Entry, T extends IDataSet<U>> {
388
395
* @param e
389
396
* @param axis
390
397
*/
391
- protected calcMinMaxForEntry ( set :IDataSet < Entry > , e : Entry , axis ) {
398
+ protected calcMinMaxForEntry ( set : IDataSet < Entry > , e : Entry , axis ) {
392
399
const xProperty = set . xProperty ;
393
400
const yProperty = set . yProperty ;
394
401
if ( this . mYMax < e [ yProperty ] ) this . mYMax = e [ yProperty ] ;
0 commit comments