ReloadData called in quick succession results in empty segments

If reloadData was called in quick succession while an animation was already running, the pie chart could end up having empty segments.

For example, if I went from a chart with 3 segments, and quickly changed to a chart that had 1 segment -then back to the three segments again, it would draw the three segment chart with only 1 segment. The other two segments would be empty spaces.

I can only assume this must be because the layersToRemove variable is getting changed in between the time of the CATransaction committing and the completion block happening. I have moved the code that was in the completion block to the end of the CATransaction (after some code that seems to already be doing some cleanup work using layersToRemove), and this seems to fix the problem. Presumably because it is all within the scope of the transaction now.

You now seem to be able to call reloadData as many times and as quickly as you like and it works ok.