Ok - I just reviewed the code after several years .... Yes it's been a while.
The way I did this was to create a Statistics BO Which I used to store the result of COUNT and SUM queries, then I generated the query on the Statistics BO and generated the Pie on that. Im my case I have a scheduled process that runs overnight which brings all the statistics records up to date, and a new record is created on the first of each month.
The code is below. It might be overkill for what you need but I'm sure you will be able to pick out the bits you need.
First - all the processing I need to do is contained as "rules" within the statisticsRecords BO - There are about 9 rules so the very act of CREATING a Record triggers all the rules and gathers my stats (see the overnight process below
Here is one of the BO rules
StatisticsRecord.ClubACLaunches=COUNT FlightLog WHERE (MONTH(FlightLog.FLDATE)=StatisticsRecord.SMonth AND YEAR(FlightLog.FLDATE)=StatisticsRecord.SYear AND FlightLog.AC_Ident.ClubAircraft='YES')
OverNight Process
CLEAN StatisticsRecord WHERE StatisticsRecord.SYear=CURRENT_YEAR AND StatisticsRecord.SMonth=CURRENT_MONTH
CREATE StatisticsRecord WITH StatisticsRecord.SYear=CURRENT_YEAR,StatisticsRecord.SMonth=CURRENT_MONTH
The first line deletes the current months stats (CLEAN is the same as delete but is performed directly in the database and so doesn't trigger any other associated rules or processes.
The second line regenerates all my stats including all the additions/changes from the previous night. The simple act of (re) creating a new record for the month triggers the rules and gathers the stats. The next step is simply to create a query or queries based on the Statistics BO and generate your Pies and Bars from that query.
In my case, I am generating one record per month so I can do month by month comparisons. In your case you generation process (it doesn't need to be overnight - it could be "on demand") would need to generate one statistics record for each TYPE. Your query on the statistics BO would then need to find all the records and you would set the X axis to be the contents of Project.Type (i.e. Fun or Not fun) and the contents of the Y axis to be the attribute that contains the count Projects.count
Hope this helps