Skip to content

Commit

Permalink
Fix element reset animations in vertical line and bubble charts (#9088)
Browse files Browse the repository at this point in the history
  • Loading branch information
nagix committed May 13, 2021
1 parent f1ca99b commit 953b23b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
16 changes: 8 additions & 8 deletions src/controllers/controller.bubble.js
Expand Up @@ -69,21 +69,21 @@ export default class BubbleController extends DatasetController {
updateElements(points, start, count, mode) {
const me = this;
const reset = mode === 'reset';
const {xScale, yScale} = me._cachedMeta;
const {iScale, vScale} = me._cachedMeta;
const firstOpts = me.resolveDataElementOptions(start, mode);
const sharedOptions = me.getSharedOptions(firstOpts);
const includeOptions = me.includeOptions(mode, sharedOptions);
const iAxis = iScale.axis;
const vAxis = vScale.axis;

for (let i = start; i < start + count; i++) {
const point = points[i];
const parsed = !reset && me.getParsed(i);
const x = reset ? xScale.getPixelForDecimal(0.5) : xScale.getPixelForValue(parsed.x);
const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(parsed.y);
const properties = {
x,
y,
skip: isNaN(x) || isNaN(y)
};
const properties = {};
const iPixel = properties[iAxis] = reset ? iScale.getPixelForDecimal(0.5) : iScale.getPixelForValue(parsed[iAxis]);
const vPixel = properties[vAxis] = reset ? vScale.getBasePixel() : vScale.getPixelForValue(parsed[vAxis]);

properties.skip = isNaN(iPixel) || isNaN(vPixel);

if (includeOptions) {
properties.options = me.resolveDataElementOptions(i, mode);
Expand Down
15 changes: 9 additions & 6 deletions src/controllers/controller.line.js
Expand Up @@ -47,10 +47,12 @@ export default class LineController extends DatasetController {
updateElements(points, start, count, mode) {
const me = this;
const reset = mode === 'reset';
const {xScale, yScale, _stacked} = me._cachedMeta;
const {iScale, vScale, _stacked} = me._cachedMeta;
const firstOpts = me.resolveDataElementOptions(start, mode);
const sharedOptions = me.getSharedOptions(firstOpts);
const includeOptions = me.includeOptions(mode, sharedOptions);
const iAxis = iScale.axis;
const vAxis = vScale.axis;
const spanGaps = me.options.spanGaps;
const maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;
const directUpdate = me.chart._animationsDisabled || reset || mode === 'none';
Expand All @@ -60,11 +62,12 @@ export default class LineController extends DatasetController {
const point = points[i];
const parsed = me.getParsed(i);
const properties = directUpdate ? point : {};
const nullData = isNullOrUndef(parsed.y);
const x = properties.x = xScale.getPixelForValue(parsed.x, i);
const y = properties.y = reset || nullData ? yScale.getBasePixel() : yScale.getPixelForValue(_stacked ? me.applyStack(yScale, parsed, _stacked) : parsed.y, i);
properties.skip = isNaN(x) || isNaN(y) || nullData;
properties.stop = i > 0 && (parsed.x - prevParsed.x) > maxGapLength;
const nullData = isNullOrUndef(parsed[vAxis]);
const iPixel = properties[iAxis] = iScale.getPixelForValue(parsed[iAxis], i);
const vPixel = properties[vAxis] = reset || nullData ? vScale.getBasePixel() : vScale.getPixelForValue(_stacked ? me.applyStack(vScale, parsed, _stacked) : parsed[vAxis], i);

properties.skip = isNaN(iPixel) || isNaN(vPixel) || nullData;
properties.stop = i > 0 && (parsed[iAxis] - prevParsed[iAxis]) > maxGapLength;
properties.parsed = parsed;

if (includeOptions) {
Expand Down

0 comments on commit 953b23b

Please sign in to comment.