@@ -41,23 +41,12 @@ public class YAxis extends AxisBase {
4141 /**
4242 * flag indicating that auto scale min restriction should be used
4343 */
44-
4544 private boolean mUseAutoScaleRestrictionMin = false ;
45+
4646 /**
4747 * flag indicating that auto scale max restriction should be used
4848 */
49-
5049 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 ;
6150
6251 /**
6352 * Color of the zero line
@@ -379,35 +368,34 @@ public boolean needsOffset() {
379368 }
380369
381370 /**
382- * Sets min value restriction for autoscale
371+ * Returns true if autoscale restriction for axis min value is enabled
383372 */
384- public void setAutoScaleMinRestriction (float restrictionValue ) {
385- mUseAutoScaleRestrictionMin = true ;
386- mAutoScaleMinRestriction = restrictionValue ;
373+ public boolean isUseAutoScaleMinRestriction ( ) {
374+ return mUseAutoScaleRestrictionMin ;
387375 }
388376
389377 /**
390- * Sets max value restriction for autoscale
378+ * Sets autoscale restriction for axis min value as enabled/disabled
391379 */
392- public void setAutoScaleMaxRestriction (float restrictionValue ) {
393- mUseAutoScaleRestrictionMax = true ;
394- mAutoScaleMaxRestriction = restrictionValue ;
380+ public void setUseAutoScaleMinRestriction ( boolean isEnabled ) {
381+ mUseAutoScaleRestrictionMin = isEnabled ;
395382 }
396383
397384 /**
398- * Resets min value restriction for autoscale
385+ * Returns true if autoscale restriction for axis max value is enabled
399386 */
400- public void resetAutoScaleMinRestriction () {
401- mUseAutoScaleRestrictionMin = false ;
387+ public boolean isUseAutoScaleMaxRestriction () {
388+ return mUseAutoScaleRestrictionMax ;
402389 }
403390
404391 /**
405- * Resets max value restriction for autoscale
392+ * Sets autoscale restriction for axis max value as enabled/disabled
406393 */
407- public void resetAutoScaleMaxRestriction ( ) {
408- mUseAutoScaleRestrictionMax = false ;
394+ public void setUseAutoScaleMaxRestriction ( boolean isEnabled ) {
395+ mUseAutoScaleRestrictionMax = isEnabled ;
409396 }
410397
398+
411399 @ Override
412400 public void calculate (float dataMin , float dataMax ) {
413401
@@ -416,15 +404,19 @@ public void calculate(float dataMin, float dataMax) {
416404
417405 // if custom, use value as is, else use data value
418406 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+ }
422412 }
423413
424414 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+ }
428420 }
429421
430422 // temporary range (before calculations)
0 commit comments