]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Line: Update points directly, when possible (#8246)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Tue, 29 Dec 2020 07:02:03 +0000 (09:02 +0200)
committerGitHub <noreply@github.com>
Tue, 29 Dec 2020 07:02:03 +0000 (09:02 +0200)
src/controllers/controller.line.js

index c3ecf7991ae4358c857da0be2ab63a4b62863a6c..e536f5d49108618e0e5a393748c15c52e70bda17 100644 (file)
@@ -51,25 +51,25 @@ export default class LineController extends DatasetController {
                const includeOptions = me.includeOptions(mode, sharedOptions);
                const spanGaps = valueOrDefault(me._config.spanGaps, me.chart.options.spanGaps);
                const maxGapLength = isNumber(spanGaps) ? spanGaps : Number.POSITIVE_INFINITY;
+               const directUpdate = me.chart._animationsDisabled || reset || mode === 'none';
                let prevParsed = start > 0 && me.getParsed(start - 1);
 
                for (let i = start; i < start + count; ++i) {
                        const point = points[i];
                        const parsed = me.getParsed(i);
-                       const x = xScale.getPixelForValue(parsed.x, i);
-                       const y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(_stacked ? me.applyStack(yScale, parsed) : parsed.y, i);
-                       const properties = {
-                               x,
-                               y,
-                               skip: isNaN(x) || isNaN(y),
-                               stop: i > 0 && (parsed.x - prevParsed.x) > maxGapLength
-                       };
+                       const properties = directUpdate ? point : {};
+                       const x = properties.x = xScale.getPixelForValue(parsed.x, i);
+                       const y = properties.y = reset ? yScale.getBasePixel() : yScale.getPixelForValue(_stacked ? me.applyStack(yScale, parsed) : parsed.y, i);
+                       properties.skip = isNaN(x) || isNaN(y);
+                       properties.stop = i > 0 && (parsed.x - prevParsed.x) > maxGapLength;
 
                        if (includeOptions) {
                                properties.options = sharedOptions || me.resolveDataElementOptions(i, mode);
                        }
 
-                       me.updateElement(point, i, properties, mode);
+                       if (!directUpdate) {
+                               me.updateElement(point, i, properties, mode);
+                       }
 
                        prevParsed = parsed;
                }