From 76d793b7ede56eab7014677e525c02d68d3d53bf Mon Sep 17 00:00:00 2001 From: Jukka Kurkela Date: Fri, 10 Jan 2020 08:55:06 +0200 Subject: [PATCH] Draw active points last --- src/controllers/controller.line.js | 18 ++++++++++++++---- src/core/core.datasetController.js | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/controllers/controller.line.js b/src/controllers/controller.line.js index 756ac9e9ddc..ddb4aa0d785 100644 --- a/src/controllers/controller.line.js +++ b/src/controllers/controller.line.js @@ -164,16 +164,26 @@ export default DatasetController.extend({ const meta = me._cachedMeta; const points = meta.data || []; const area = chart.chartArea; - const ilen = points.length; - let i = 0; + const active = []; + let ilen = points.length; + let i, point; if (me._showLine) { meta.dataset.draw(ctx, area); } + // Draw the points - for (; i < ilen; ++i) { - points[i].draw(ctx, area); + for (i = 0; i < ilen; ++i) { + point = points[i]; + if (point.active) { + active.push(point); + } else { + point.draw(ctx, area); + } + } + for (i = 0, ilen = active.length; i < ilen; ++i) { + active[i].draw(ctx, area); } }, }); diff --git a/src/core/core.datasetController.js b/src/core/core.datasetController.js index 1db4dcfcd55..abe8e461491 100644 --- a/src/core/core.datasetController.js +++ b/src/core/core.datasetController.js @@ -1006,6 +1006,7 @@ helpers.extend(DatasetController.prototype, { * @private */ _setStyle(element, index, mode, active) { + element.active = active; this._resolveAnimations(index, mode, active).update(element, {options: this.getStyle(index, active)}); },