How do I efficiently summarize my data for a ChartJS Doughnut or Pie?

I want to build a doughnut / pie / single series chart using ChartJS. This requires me to: 1. Fill in the total value into the Chart object 2. Fill in one value for each slice in the Dataset object It's #2 that I'd like to know about: What is the easy way to get a total value for each of my slices to put into the Dataset? Outside of Mendix I'd do a Count/Group By query. What's the best practice within Mendix? How do I implement this in a Microflow?  
2 answers


I have an example that is the datasource for a Pie chart.  It produces a pie chart for energy usage for a building.  The pie slices are electricity, gas and oil.  Model Share here:

Picture below:


Rob - here is an example with a dynamic number of pie pieces:

Model share here:

****END OF EDIT******

Hope that helps,



Thanks for this example, but it has one problem: The pie slices are hard-coded. What if I want to summarize open tasks in a process list by owner. It could be any X owners of 500 name users. What then?