From: Akihiko Kusanagi Date: Thu, 13 May 2021 20:22:58 +0000 (+0800) Subject: Fix element reset animations in vertical line and bubble charts (#9088) X-Git-Tag: v3.3.0~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=953b23b4ef0f6e7973bf91538a1ae5f9eabff216;p=thirdparty%2FChart.js.git Fix element reset animations in vertical line and bubble charts (#9088) --- diff --git a/src/controllers/controller.bubble.js b/src/controllers/controller.bubble.js index 8cad718b9..115012a14 100644 --- a/src/controllers/controller.bubble.js +++ b/src/controllers/controller.bubble.js @@ -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); diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index 2c7260495..0346da426 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -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'; @@ -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) {