From a920bfe34f3cb5abe51eb73315fc060c7240a2dd Mon Sep 17 00:00:00 2001 From: Jukka Kurkela Date: Fri, 1 Nov 2019 00:13:06 +0200 Subject: [PATCH] Hide correct dataset from legend (#6661) --- src/plugins/plugin.legend.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/plugin.legend.js b/src/plugins/plugin.legend.js index c358ff6804c..e790e9ba43e 100644 --- a/src/plugins/plugin.legend.js +++ b/src/plugins/plugin.legend.js @@ -53,13 +53,13 @@ defaults._set('global', { var options = chart.options.legend || {}; var usePointStyle = options.labels && options.labels.usePointStyle; - return chart._getSortedDatasetMetas().map(function(meta, i) { + return chart._getSortedDatasetMetas().map(function(meta) { var style = meta.controller.getStyle(usePointStyle ? 0 : undefined); return { text: datasets[meta.index].label, fillStyle: style.backgroundColor, - hidden: !chart.isDatasetVisible(i), + hidden: !chart.isDatasetVisible(meta.index), lineCap: style.borderCapStyle, lineDash: style.borderDash, lineDashOffset: style.borderDashOffset, @@ -70,7 +70,7 @@ defaults._set('global', { rotation: style.rotation, // Below is extra data used for toggling the datasets - datasetIndex: i + datasetIndex: meta.index }; }, this); }