Skip to content

Commit 95a3664

Browse files
committed
fix: correct bar animations when “bottom” is > 0
1 parent 5304ba8 commit 95a3664

File tree

3 files changed

+24
-35
lines changed

3 files changed

+24
-35
lines changed

src/charting/buffer/BarBuffer.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ export class BarBuffer extends AbstractBuffer<IBarDataSet> {
7777

7878
// multiply the height of the rect with the phase
7979
if (top > 0) {
80-
top *= this.phaseY;
80+
top = bottom + this.phaseY * (top - bottom);
8181
} else {
82-
bottom *= this.phaseY;
82+
bottom = top + this.phaseY * (bottom - top);
8383
}
8484

8585
this.addBar(left, top, right, bottom);
@@ -119,8 +119,11 @@ export class BarBuffer extends AbstractBuffer<IBarDataSet> {
119119
}
120120

121121
// multiply the height of the rect with the phase
122-
top *= this.phaseY;
123-
bottom *= this.phaseY;
122+
if (top > 0) {
123+
top = bottom + this.phaseY * (top - bottom);
124+
} else {
125+
bottom = top + this.phaseY * (bottom - top);
126+
}
124127

125128
this.addBar(left, top, right, bottom);
126129
}

src/charting/buffer/HorizontalBarBuffer.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export class HorizontalBarBuffer extends BarBuffer {
3636

3737
// multiply the height of the rect with the phase
3838
if (right > 0) {
39-
right *= this.phaseY;
39+
right = left + this.phaseY * (right - left);
4040
} else {
41-
left *= this.phaseY;
41+
left = right + this.phaseY * (left - right);
4242
}
4343
this.addBar(left, top, right, bottom);
4444
} else {
@@ -72,8 +72,11 @@ export class HorizontalBarBuffer extends BarBuffer {
7272
}
7373

7474
// multiply the height of the rect with the phase
75-
right *= this.phaseY;
76-
left *= this.phaseY;
75+
if (right > 0) {
76+
right = left + this.phaseY * (right - left);
77+
} else {
78+
left = right + this.phaseY * (left - right);
79+
}
7780

7881
this.addBar(left, top, right, bottom);
7982
}

src/charting/utils/Transformer.ts

+10-27
Original file line numberDiff line numberDiff line change
@@ -320,37 +320,24 @@ export class Transformer {
320320
*/
321321
public rectToPixelPhase(r: Rect, phaseY) {
322322
// multiply the height of the rect with the phase
323-
r.top *= phaseY;
324-
r.bottom *= phaseY;
323+
if (r.top > 0) {
324+
r.top = r.bottom + phaseY * (r.top - r.bottom);
325+
} else {
326+
r.bottom = r.top + phaseY * (r.bottom - r.top);
327+
}
325328
this.rectValueToPixel(r);
326-
327-
// this.mMatrixValueToPx.mapRect(r);
328-
// this.mViewPortHandler.getMatrixTouch().mapRect(r);
329-
// this.mMatrixOffset.mapRect(r);
330329
}
331330

332331
public rectToPixelPhaseHorizontal(r: Rect, phaseY) {
333332
// multiply the height of the rect with the phase
334-
r.left *= phaseY;
335-
r.right *= phaseY;
333+
if (r.left > 0) {
334+
r.left = r.right + phaseY * (r.left - r.right);
335+
} else {
336+
r.right = r.left + phaseY * (r.right - r.left);
337+
}
336338
this.rectValueToPixel(r);
337-
338-
// this.mMatrixValueToPx.mapRect(r);
339-
// this.mViewPortHandler.getMatrixTouch().mapRect(r);
340-
// this.mMatrixOffset.mapRect(r);
341339
}
342340

343-
/**
344-
* Transform a rectangle with all matrices with potential animation phases.
345-
*
346-
* @param r
347-
*/
348-
// public rectValueToPixelHorizontal(r: Rect) {
349-
// this.mMatrixValueToPx.mapRect(r);
350-
// this.mViewPortHandler.getMatrixTouch().mapRect(r);
351-
// this.mMatrixOffset.mapRect(r);
352-
// }
353-
354341
/**
355342
* Transform a rectangle with all matrices with potential animation phases.
356343
*
@@ -364,10 +351,6 @@ export class Transformer {
364351
r.right *= phaseY;
365352
}
366353
this.rectValueToPixel(r);
367-
368-
// this.mMatrixValueToPx.mapRect(r);
369-
// this.mViewPortHandler.getMatrixTouch().mapRect(r);
370-
// this.mMatrixOffset.mapRect(r);
371354
}
372355

373356
/**

0 commit comments

Comments
 (0)