@@ -38,6 +38,16 @@ public class YAxis extends AxisBase {
38
38
*/
39
39
protected boolean mDrawZeroLine = false ;
40
40
41
+ /**
42
+ * flag indicating that auto scale min restriction should be used
43
+ */
44
+ private boolean mUseAutoScaleRestrictionMin = false ;
45
+
46
+ /**
47
+ * flag indicating that auto scale max restriction should be used
48
+ */
49
+ private boolean mUseAutoScaleRestrictionMax = false ;
50
+
41
51
/**
42
52
* Color of the zero line
43
53
*/
@@ -357,12 +367,57 @@ public boolean needsOffset() {
357
367
return false ;
358
368
}
359
369
370
+ /**
371
+ * Returns true if autoscale restriction for axis min value is enabled
372
+ */
373
+ public boolean isUseAutoScaleMinRestriction ( ) {
374
+ return mUseAutoScaleRestrictionMin ;
375
+ }
376
+
377
+ /**
378
+ * Sets autoscale restriction for axis min value as enabled/disabled
379
+ */
380
+ public void setUseAutoScaleMinRestriction ( boolean isEnabled ) {
381
+ mUseAutoScaleRestrictionMin = isEnabled ;
382
+ }
383
+
384
+ /**
385
+ * Returns true if autoscale restriction for axis max value is enabled
386
+ */
387
+ public boolean isUseAutoScaleMaxRestriction () {
388
+ return mUseAutoScaleRestrictionMax ;
389
+ }
390
+
391
+ /**
392
+ * Sets autoscale restriction for axis max value as enabled/disabled
393
+ */
394
+ public void setUseAutoScaleMaxRestriction ( boolean isEnabled ) {
395
+ mUseAutoScaleRestrictionMax = isEnabled ;
396
+ }
397
+
398
+
360
399
@ Override
361
400
public void calculate (float dataMin , float dataMax ) {
362
401
402
+ float min = dataMin ;
403
+ float max = dataMax ;
404
+
363
405
// if custom, use value as is, else use data value
364
- float min = mCustomAxisMin ? mAxisMinimum : dataMin ;
365
- float max = mCustomAxisMax ? mAxisMaximum : dataMax ;
406
+ if ( mCustomAxisMin ) {
407
+ if ( mUseAutoScaleRestrictionMin ) {
408
+ min = Math .min ( dataMin , mAxisMinimum );
409
+ } else {
410
+ min = mAxisMinimum ;
411
+ }
412
+ }
413
+
414
+ if ( mCustomAxisMax ) {
415
+ if ( mUseAutoScaleRestrictionMax ) {
416
+ max = Math .max ( max , mAxisMaximum );
417
+ } else {
418
+ max = mAxisMaximum ;
419
+ }
420
+ }
366
421
367
422
// temporary range (before calculations)
368
423
float range = Math .abs (max - min );
0 commit comments