Skip to content

Commit

Permalink
Merge pull request #1061 from danielgindi/highlight-animation-fix
Browse files Browse the repository at this point in the history
Fix highlight animation bug in stacked bar chart
  • Loading branch information
PhilJay committed Oct 1, 2015
2 parents 10a392d + 8bb5e1a commit 497beac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ public void drawHighlighted(Canvas c, Highlight[] indices) {

if (isStack) {
y1 = h.getRange().from;
y2 = h.getRange().to * mAnimator.getPhaseY();
y2 = h.getRange().to;
} else {
y1 = e.getVal();
y2 = 0.f;
Expand All @@ -370,7 +370,7 @@ public void drawHighlighted(Canvas c, Highlight[] indices) {
final float arrowWidth = set.getBarSpace() / 2.f;
final float arrowHeight = arrowWidth * xToYRel;

final float yArrow = y1 > -y2 ? y1 : y1;
final float yArrow = (y1 > -y2 ? y1 : y1) * mAnimator.getPhaseY();

Path arrow = new Path();
arrow.moveTo(x + 0.4f, yArrow + offsetY);
Expand Down
25 changes: 17 additions & 8 deletions MPChartLib/src/com/github/mikephil/charting/utils/Transformer.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,21 @@ public void rectValueToPixel(RectF r) {
public void rectValueToPixel(RectF r, float phaseY) {

// multiply the height of the rect with the phase
if (r.top > 0)
r.top *= phaseY;
else
r.bottom *= phaseY;
r.top *= phaseY;
r.bottom *= phaseY;

mMatrixValueToPx.mapRect(r);
mViewPortHandler.getMatrixTouch().mapRect(r);
mMatrixOffset.mapRect(r);
}

/**
* Transform a rectangle with all matrices with potential animation phases.
*
* @param r
*/
public void rectValueToPixelHorizontal(RectF r) {

mMatrixValueToPx.mapRect(r);
mViewPortHandler.getMatrixTouch().mapRect(r);
Expand All @@ -353,10 +364,8 @@ public void rectValueToPixel(RectF r, float phaseY) {
public void rectValueToPixelHorizontal(RectF r, float phaseY) {

// multiply the height of the rect with the phase
if (r.left > 0)
r.left *= phaseY;
else
r.right *= phaseY;
r.left *= phaseY;
r.right *= phaseY;

mMatrixValueToPx.mapRect(r);
mViewPortHandler.getMatrixTouch().mapRect(r);
Expand Down

0 comments on commit 497beac

Please sign in to comment.