It is more complex then you would expect, mainly because of the buildup of the data. You can copy paste from https://mydemoversion8-sandbox.mxapps.io/p/charts. Have a look. It contains a lot of charts.
You can download the .mpk of that app at https://github.com/TimvanSteenbergen/MyDemoVersion8. In that app, see module Charts and look for the pie.