Merge pull request #3642 from pagrzybe/autoscale_restrictions
Option to set restrictions for Y axis autoscaling.
This commit is contained in:
commit
73054bedc3
1 changed files with 57 additions and 2 deletions
|
@ -38,6 +38,16 @@ public class YAxis extends AxisBase {
|
|||
*/
|
||||
protected boolean mDrawZeroLine = false;
|
||||
|
||||
/**
|
||||
* flag indicating that auto scale min restriction should be used
|
||||
*/
|
||||
private boolean mUseAutoScaleRestrictionMin = false;
|
||||
|
||||
/**
|
||||
* flag indicating that auto scale max restriction should be used
|
||||
*/
|
||||
private boolean mUseAutoScaleRestrictionMax = false;
|
||||
|
||||
/**
|
||||
* Color of the zero line
|
||||
*/
|
||||
|
@ -357,12 +367,57 @@ public class YAxis extends AxisBase {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if autoscale restriction for axis min value is enabled
|
||||
*/
|
||||
public boolean isUseAutoScaleMinRestriction( ) {
|
||||
return mUseAutoScaleRestrictionMin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets autoscale restriction for axis min value as enabled/disabled
|
||||
*/
|
||||
public void setUseAutoScaleMinRestriction( boolean isEnabled ) {
|
||||
mUseAutoScaleRestrictionMin = isEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if autoscale restriction for axis max value is enabled
|
||||
*/
|
||||
public boolean isUseAutoScaleMaxRestriction() {
|
||||
return mUseAutoScaleRestrictionMax;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets autoscale restriction for axis max value as enabled/disabled
|
||||
*/
|
||||
public void setUseAutoScaleMaxRestriction( boolean isEnabled ) {
|
||||
mUseAutoScaleRestrictionMax = isEnabled;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void calculate(float dataMin, float dataMax) {
|
||||
|
||||
float min = dataMin;
|
||||
float max = dataMax;
|
||||
|
||||
// if custom, use value as is, else use data value
|
||||
float min = mCustomAxisMin ? mAxisMinimum : dataMin;
|
||||
float max = mCustomAxisMax ? mAxisMaximum : dataMax;
|
||||
if( mCustomAxisMin ) {
|
||||
if( mUseAutoScaleRestrictionMin ) {
|
||||
min = Math.min( dataMin, mAxisMinimum );
|
||||
} else {
|
||||
min = mAxisMinimum;
|
||||
}
|
||||
}
|
||||
|
||||
if( mCustomAxisMax ) {
|
||||
if( mUseAutoScaleRestrictionMax ) {
|
||||
max = Math.max( max, mAxisMaximum );
|
||||
} else {
|
||||
max = mAxisMaximum;
|
||||
}
|
||||
}
|
||||
|
||||
// temporary range (before calculations)
|
||||
float range = Math.abs(max - min);
|
||||
|
|
Loading…
Add table
Reference in a new issue