Fixed issue that restrained the viewport after returning from a locked screen.
This commit is contained in:
parent
d930ac232f
commit
34fe3c547b
3 changed files with 24 additions and 5 deletions
|
@ -128,10 +128,10 @@ public class LineChartActivity extends Activity implements OnSeekBarChangeListen
|
|||
setData(45, 100);
|
||||
|
||||
// restrain the maximum scale-out factor
|
||||
// mChart.setScaleMinima(3f, 3f);
|
||||
mChart.setScaleMinima(3f, 3f);
|
||||
|
||||
// center the view to a specific position inside the chart
|
||||
// mChart.centerViewPort(10, 50);
|
||||
mChart.centerViewPort(10, 50);
|
||||
|
||||
// get the legend (only possible after setting data)
|
||||
Legend l = mChart.getLegend();
|
||||
|
|
|
@ -1007,7 +1007,7 @@ public abstract class BarLineChartBase extends Chart {
|
|||
transformPointArray(pts);
|
||||
|
||||
final float x = -pts[0] + getOffsetLeft();
|
||||
final float y = -pts[1] + getOffsetBottom();
|
||||
final float y = -pts[1] - getOffsetTop();
|
||||
|
||||
save.postTranslate(x, y);
|
||||
|
||||
|
@ -1649,6 +1649,18 @@ public abstract class BarLineChartBase extends Chart {
|
|||
public float getScaleY() {
|
||||
return mScaleY;
|
||||
}
|
||||
|
||||
/**
|
||||
* if the chart is fully zoomed out, return true
|
||||
* @return
|
||||
*/
|
||||
public boolean isFullyZoomedOut() {
|
||||
|
||||
// Log.i(LOG_TAG, "MinScaleX: " + mMinScaleX + ", ScaleX: " + mScaleX);
|
||||
|
||||
if(mScaleX <= mMinScaleX && mScaleY <= mMinScaleY) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* calcualtes the maximum x-scale value depending on the number of x-values,
|
||||
|
|
|
@ -407,7 +407,7 @@ public abstract class Chart extends View {
|
|||
mMatrixOffset.reset();
|
||||
mMatrixOffset.postTranslate(mOffsetLeft, getHeight() - mOffsetBottom);
|
||||
|
||||
// Log.i(LOG_TAG, "Matrices prepared.");
|
||||
Log.i(LOG_TAG, "Matrices prepared.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1594,6 +1594,8 @@ public abstract class Chart extends View {
|
|||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
private boolean mMatrixOnLayoutPrepared = false;
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
|
@ -1604,9 +1606,14 @@ public abstract class Chart extends View {
|
|||
|
||||
if (this instanceof BarLineChartBase) {
|
||||
|
||||
BarLineChartBase b = (BarLineChartBase) this;
|
||||
|
||||
// if y-values are not fixed
|
||||
if (!((BarLineChartBase) this).hasFixedYValues())
|
||||
if (!b.hasFixedYValues() && !mMatrixOnLayoutPrepared) {
|
||||
prepareMatrix();
|
||||
mMatrixOnLayoutPrepared = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
prepareMatrix();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue