Skip to content

Commit

Permalink
Hide correct dataset from legend (chartjs#6661)
Browse files Browse the repository at this point in the history
  • Loading branch information
kurkle authored and etimberg committed Nov 2, 2019
1 parent e0c0103 commit 6ffdfa8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/plugins/plugin.legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
Expand Down

0 comments on commit 6ffdfa8

Please sign in to comment.