From: Jukka Kurkela Date: Fri, 1 Nov 2019 18:06:08 +0000 (+0200) Subject: Hide correct dataset from legend (#6667) X-Git-Tag: v3.0.0-alpha~274 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6942e9058c06494105b42f4efd18f80b2ab64ac1;p=thirdparty%2FChart.js.git Hide correct dataset from legend (#6667) --- diff --git a/src/plugins/plugin.legend.js b/src/plugins/plugin.legend.js index c358ff680..e790e9ba4 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); }