Skip to content

Commit 5c826af

Browse files
authored
Merge pull request #101 from AdeelK93/patch-1
Keep legend length in sync with data length
2 parents c8e84aa + 6bdf66f commit 5c826af

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ class ChartComponent extends React.Component {
117117
// seamless transitions
118118
let currentDatasets = (this.chart_instance.config.data && this.chart_instance.config.data.datasets) || [];
119119
const nextDatasets = data.datasets || [];
120+
121+
// Prevent charting of legend items that no longer exist
122+
while (currentDatasets.length > nextDatasets.length) {
123+
currentDatasets.pop();
124+
}
120125

121126
nextDatasets.forEach((dataset, sid) => {
122127
if (currentDatasets[sid] && currentDatasets[sid].data) {

0 commit comments

Comments
 (0)