Fix for pie charts with no data

When you create a pie chart and then filter so that the pie chart has no data (no results), AND you have the legend enabled (which it is by default), you get an error.

This change adds an extra null check to make sure a property is defined before accessing it.

Closes #1958.