@@ -41,23 +41,12 @@ public class YAxis extends AxisBase {
41
41
/**
42
42
* flag indicating that auto scale min restriction should be used
43
43
*/
44
-
45
44
private boolean mUseAutoScaleRestrictionMin = false ;
45
+
46
46
/**
47
47
* flag indicating that auto scale max restriction should be used
48
48
*/
49
-
50
49
private boolean mUseAutoScaleRestrictionMax = false ;
51
- /**
52
- * restriction value of autoscale min
53
- */
54
-
55
- private float mAutoScaleMinRestriction = 0f ;
56
-
57
- /**
58
- * restriction value of autoscale max
59
- */
60
- private float mAutoScaleMaxRestriction = 0f ;
61
50
62
51
/**
63
52
* Color of the zero line
@@ -379,35 +368,34 @@ public boolean needsOffset() {
379
368
}
380
369
381
370
/**
382
- * Sets min value restriction for autoscale
371
+ * Returns true if autoscale restriction for axis min value is enabled
383
372
*/
384
- public void setAutoScaleMinRestriction (float restrictionValue ) {
385
- mUseAutoScaleRestrictionMin = true ;
386
- mAutoScaleMinRestriction = restrictionValue ;
373
+ public boolean isUseAutoScaleMinRestriction ( ) {
374
+ return mUseAutoScaleRestrictionMin ;
387
375
}
388
376
389
377
/**
390
- * Sets max value restriction for autoscale
378
+ * Sets autoscale restriction for axis min value as enabled/disabled
391
379
*/
392
- public void setAutoScaleMaxRestriction (float restrictionValue ) {
393
- mUseAutoScaleRestrictionMax = true ;
394
- mAutoScaleMaxRestriction = restrictionValue ;
380
+ public void setUseAutoScaleMinRestriction ( boolean isEnabled ) {
381
+ mUseAutoScaleRestrictionMin = isEnabled ;
395
382
}
396
383
397
384
/**
398
- * Resets min value restriction for autoscale
385
+ * Returns true if autoscale restriction for axis max value is enabled
399
386
*/
400
- public void resetAutoScaleMinRestriction () {
401
- mUseAutoScaleRestrictionMin = false ;
387
+ public boolean isUseAutoScaleMaxRestriction () {
388
+ return mUseAutoScaleRestrictionMax ;
402
389
}
403
390
404
391
/**
405
- * Resets max value restriction for autoscale
392
+ * Sets autoscale restriction for axis max value as enabled/disabled
406
393
*/
407
- public void resetAutoScaleMaxRestriction ( ) {
408
- mUseAutoScaleRestrictionMax = false ;
394
+ public void setUseAutoScaleMaxRestriction ( boolean isEnabled ) {
395
+ mUseAutoScaleRestrictionMax = isEnabled ;
409
396
}
410
397
398
+
411
399
@ Override
412
400
public void calculate (float dataMin , float dataMax ) {
413
401
@@ -416,15 +404,19 @@ public void calculate(float dataMin, float dataMax) {
416
404
417
405
// if custom, use value as is, else use data value
418
406
if ( mCustomAxisMin ) {
419
- min = mAxisMinimum ;
420
- } else if ( mUseAutoScaleRestrictionMin ) {
421
- min = Math .min ( min , mAutoScaleMinRestriction );
407
+ if ( mUseAutoScaleRestrictionMin ) {
408
+ min = Math .min ( dataMin , mAxisMinimum );
409
+ } else {
410
+ min = mAxisMinimum ;
411
+ }
422
412
}
423
413
424
414
if ( mCustomAxisMax ) {
425
- max = mAxisMaximum ;
426
- } else if ( mUseAutoScaleRestrictionMax ) {
427
- max = Math .max ( max , mAutoScaleMaxRestriction );
415
+ if ( mUseAutoScaleRestrictionMax ) {
416
+ max = Math .max ( max , mAxisMaximum );
417
+ } else {
418
+ max = mAxisMaximum ;
419
+ }
428
420
}
429
421
430
422
// temporary range (before calculations)
0 commit comments