Work on viewport modifications for horizontal barchart (issue #1842)
This commit is contained in:
parent
72890afc10
commit
ded930a2fa
4 changed files with 45 additions and 12 deletions
|
@ -57,5 +57,5 @@ dependencies {
|
|||
compile project(':MPChartLib') // remove this if you only imported the example project
|
||||
compile 'com.android.support:appcompat-v7:23.1.1'
|
||||
compile 'io.realm:realm-android:0.87.5' // dependency for realm-database API (http://realm.io)
|
||||
//compile 'com.github.PhilJay:MPAndroidChart:v2.2.0'
|
||||
//compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'
|
||||
}
|
||||
|
|
|
@ -719,7 +719,7 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
|
|||
/**
|
||||
* Sets the size of the area (range on the x-axis) that should be maximum
|
||||
* visible at once (no further zooming out allowed). If this is e.g. set to
|
||||
* 10, no more than 10 values on the x-axis can be viewed at once without
|
||||
* 10, no more than a range of 10 on the x-axis can be viewed at once without
|
||||
* scrolling.
|
||||
*
|
||||
* @param maxXRange The maximum visible range of x-values.
|
||||
|
@ -732,7 +732,7 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
|
|||
/**
|
||||
* Sets the size of the area (range on the x-axis) that should be minimum
|
||||
* visible at once (no further zooming in allowed). If this is e.g. set to
|
||||
* 10, no less than 10 values on the x-axis can be viewed at once without
|
||||
* 10, no less than a range of 10 on the x-axis can be viewed at once without
|
||||
* scrolling.
|
||||
*
|
||||
* @param minXRange The minimum visible range of x-values.
|
||||
|
@ -743,9 +743,8 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
|
|||
}
|
||||
|
||||
/**
|
||||
* Limits the maximum and minimum value count that can be visible by
|
||||
* pinching and zooming. e.g. minRange=10, maxRange=100 no less than 10
|
||||
* values and no more that 100 values can be viewed at once without
|
||||
* Limits the maximum and minimum x range that can be visible by pinching and zooming. e.g. minRange=10, maxRange=100 the
|
||||
* smallest range to be displayed at once is 10, and no more than a range of 100 values can be viewed at once without
|
||||
* scrolling
|
||||
*
|
||||
* @param minXRange
|
||||
|
@ -770,14 +769,14 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
|
|||
}
|
||||
|
||||
/**
|
||||
* Moves the left side of the current viewport to the specified x-index.
|
||||
* Moves the left side of the current viewport to the specified x-position.
|
||||
* This also refreshes the chart by calling invalidate().
|
||||
*
|
||||
* @param xIndex
|
||||
* @param xValue
|
||||
*/
|
||||
public void moveViewToX(float xIndex) {
|
||||
public void moveViewToX(float xValue) {
|
||||
|
||||
Runnable job = new MoveViewJob(mViewPortHandler, xIndex, 0f,
|
||||
Runnable job = new MoveViewJob(mViewPortHandler, xValue, 0f,
|
||||
getTransformer(AxisDependency.LEFT), this);
|
||||
|
||||
addViewportJob(job);
|
||||
|
@ -802,7 +801,7 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
|
|||
|
||||
/**
|
||||
* This will move the left side of the current viewport to the specified
|
||||
* x value on the x-axis, and center the viewport to the specified y value on the y-axis.
|
||||
* x-value on the x-axis, and center the viewport to the specified y value on the y-axis.
|
||||
* This also refreshes the chart by calling invalidate().
|
||||
*
|
||||
* @param xValue
|
||||
|
@ -820,7 +819,7 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleBubbleData<
|
|||
}
|
||||
|
||||
/**
|
||||
* This will move the left side of the current viewport to the specified x value
|
||||
* This will move the left side of the current viewport to the specified x-value
|
||||
* and center the viewport to the y value animated.
|
||||
* This also refreshes the chart by calling invalidate().
|
||||
*
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.util.AttributeSet;
|
|||
import android.util.Log;
|
||||
|
||||
import com.github.mikephil.charting.components.XAxis.XAxisPosition;
|
||||
import com.github.mikephil.charting.components.YAxis;
|
||||
import com.github.mikephil.charting.components.YAxis.AxisDependency;
|
||||
import com.github.mikephil.charting.data.BarEntry;
|
||||
import com.github.mikephil.charting.data.Entry;
|
||||
|
@ -205,4 +206,23 @@ public class HorizontalBarChart extends BarChart {
|
|||
mViewPortHandler.contentTop());
|
||||
return (float) Math.min(mXAxis.mAxisMaximum, pos.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibleXRangeMaximum(float maxXRange) {
|
||||
float xScale = mXAxis.mAxisRange / (maxXRange);
|
||||
mViewPortHandler.setMinimumScaleY(xScale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibleYRangeMaximum(float maxYRange, AxisDependency axis) {
|
||||
float yScale = getDeltaY(axis) / maxYRange;
|
||||
mViewPortHandler.setMinimumScaleX(yScale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisibleXRange(float minXRange, float maxXRange) {
|
||||
float maxScale = mXAxis.mAxisRange / minXRange;
|
||||
float minScale = mXAxis.mAxisRange / maxXRange;
|
||||
mViewPortHandler.setMinMaxScaleY(minScale, maxScale);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -509,6 +509,20 @@ public class ViewPortHandler {
|
|||
limitTransAndScale(mMatrixTouch, mContentRect);
|
||||
}
|
||||
|
||||
public void setMinMaxScaleY(float minScaleY, float maxScaleY) {
|
||||
|
||||
if (minScaleY < 1f)
|
||||
minScaleY = 1f;
|
||||
|
||||
if (maxScaleY == 0.f)
|
||||
maxScaleY = Float.MAX_VALUE;
|
||||
|
||||
mMinScaleX = minScaleY;
|
||||
mMaxScaleX = maxScaleY;
|
||||
|
||||
limitTransAndScale(mMatrixTouch, mContentRect);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the charts-touch matrix used for translation and scale on touch.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue