From 051f5b015bc9d1fb07cd23ec3bfc78e6e3914360 Mon Sep 17 00:00:00 2001 From: Zach Panzarino Date: Fri, 16 Sep 2016 01:29:01 +0000 Subject: [PATCH] Fix bug with pie/doughnut chart legends Fixes a rendering issue when there are multiple datasets on a pie chart and they do not all contain the same number of data in their datasets Fixes #3309 --- src/controllers/controller.doughnut.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/controllers/controller.doughnut.js b/src/controllers/controller.doughnut.js index 0e9c5fe80..e0f378dae 100644 --- a/src/controllers/controller.doughnut.js +++ b/src/controllers/controller.doughnut.js @@ -76,7 +76,10 @@ module.exports = function(Chart) { for (i = 0, ilen = (chart.data.datasets || []).length; i < ilen; ++i) { meta = chart.getDatasetMeta(i); - meta.data[index].hidden = !meta.data[index].hidden; + // toggle visibility of index if exists + if (meta.data[index]) { + meta.data[index].hidden = !meta.data[index].hidden; + } } chart.update(); -- 2.47.2