I am working with a pair of PIE charts. Each cover the same theme of data and can have the same slice items. However, not all legend items appear in both PIEs all the time. I have looked at several solutions to this (this one being the closest). However, it breaks when one of the PIEs does not have all the slices that the other has.
Test case jsFiddle shows that the first PIE does not have the 'Engineering'
slice while the second PIE does. But, this means that the item does not show up in the legend. How can I get all unique entries in each PIE's legend in one single legend?
This is the current callback function (notice it is based on series[0]):
$(chart.series[0].data).each(function(i, e) {
e.legendItem.on('click', function(event) {
var legendItem = e.name;
event.stopPropagation();
$(chart.series).each(function(j, f) {
$(this.data).each(function(k, z) {
if (z.name == legendItem) {
if (z.visible) {
z.setVisible(false);
} else {
z.setVisible(true);
}
}
});
});
});
});