From f191f2f5f9a1e1e1a95f1722b41d168244b1d554 Mon Sep 17 00:00:00 2001 From: LeeLenaleee <39033624+LeeLenaleee@users.noreply.github.com> Date: Wed, 16 Dec 2020 22:40:10 +0100 Subject: [PATCH] Remove dataset while hovered (#8181) --- src/core/core.controller.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/core.controller.js b/src/core/core.controller.js index b4d200d4bfe..80632579d80 100644 --- a/src/core/core.controller.js +++ b/src/core/core.controller.js @@ -725,7 +725,7 @@ class Chart { hidden: null, // See isDatasetVisible() comment xAxisID: null, yAxisID: null, - order: dataset.order || 0, + order: dataset && dataset.order || 0, index: datasetIndex, _dataset: dataset, _parsed: [], @@ -808,7 +808,7 @@ class Chart { const me = this; const meta = me._metasets && me._metasets[datasetIndex]; - if (meta) { + if (meta && meta.controller) { meta.controller._destroy(); delete me._metasets[datasetIndex]; } @@ -933,8 +933,9 @@ class Chart { for (i = 0, ilen = items.length; i < ilen; ++i) { item = items[i]; - if (item) { - this.getDatasetMeta(item.datasetIndex).controller[prefix + 'HoverStyle'](item.element, item.datasetIndex, item.index); + const controller = item && this.getDatasetMeta(item.datasetIndex).controller; + if (controller) { + controller[prefix + 'HoverStyle'](item.element, item.datasetIndex, item.index); } } }