Fix issue in highlight animation for barchart

This commit is contained in:
Philipp Jahoda 2016-06-04 14:44:39 +02:00
parent b5cf9e120b
commit cee380be6c
3 changed files with 16 additions and 4 deletions

View file

@ -178,7 +178,7 @@ public class BarChartRenderer extends DataRenderer {
mBarRect.set(left, top, right, bottom);
trans.rectValueToPixel(mBarRect, mAnimator.getPhaseY());
trans.rectToPixelPhase(mBarRect, mAnimator.getPhaseY());
}
@Override
@ -358,8 +358,9 @@ public class BarChartRenderer extends DataRenderer {
float x = high.getX();
BarEntry e = set.getEntryForXPos(x);
float entryIndex = set.getEntryIndex(e);
if (e == null)
if (e == null || entryIndex > set.getEntryCount() * mAnimator.getPhaseX())
continue;
boolean isStack = high.getStackIndex() < 0 ? false : true;

View file

@ -288,7 +288,7 @@ public class HorizontalBarChartRenderer extends BarChartRenderer {
mBarRect.set(left, top, right, bottom);
trans.rectValueToPixel(mBarRect, mAnimator.getPhaseY());
trans.rectToPixelPhaseHorizontal(mBarRect, mAnimator.getPhaseY());
}
@Override

View file

@ -300,7 +300,7 @@ public class Transformer {
* @param r
* @param phaseY
*/
public void rectValueToPixel(RectF r, float phaseY) {
public void rectToPixelPhase(RectF r, float phaseY) {
// multiply the height of the rect with the phase
r.top *= phaseY;
@ -311,6 +311,17 @@ public class Transformer {
mMatrixOffset.mapRect(r);
}
public void rectToPixelPhaseHorizontal(RectF r, float phaseY) {
// multiply the height of the rect with the phase
r.left *= phaseY;
r.right *= phaseY;
mMatrixValueToPx.mapRect(r);
mViewPortHandler.getMatrixTouch().mapRect(r);
mMatrixOffset.mapRect(r);
}
/**
* Transform a rectangle with all matrices with potential animation phases.
*