I have a site where users can submit change requests. I created a custom content type "Change Request" which has numerous fields in it, some of which I want to generate charts for.
One of these fields is a list called "urgency" which includes the options "Low", "Medium" and "High". Only one option can be selected per change request.
I created 4 change requests with sample data which I am using to generate a chart. My goal is to create a pie chart that shows the number of change requests that falls under each urgency level.
I am experiencing two related issues which I believe are stemming from an issue with my aggregation settings. First, the labels are being duplicated, and second, those duplicated values are being counted and charted separately instead of being combined into one item on the chart.
For example, I have 2 change requests that are "Low" urgency, and the other two change requests are "Medium" and "High" respectively. Instead of having this reflected in the pie chart, it is showing "Low" as two separate labels, and both of them has a count of 1. These should be instead combined into a single label with a count of 2. I understand that I need to aggregate the results, but I am struggling to achieve this.
- I created a new view called "Overview".
- The view settings are set to show Content of type "change requests".
- I enabled create a page and set it to display a chart of fields.
- I enabled Advanced > Other > Use aggregation on the display.
- I added the Urgency field to be used as a label.
- I added the Urgency field a second time to be used as data. For this, I attempted multiple aggregation functions listed below in attempts. This is the same urgency field, but I am using it once for labels, and again to count the number of requests for each value in the field.
- I clicked Format > Chart > Settings and set my label and data fields to match the above fields.
First Attempt: Using Field Count Formatter
- I tried using the Field Count Formatter module at first, but I discovered that this was not counting the amount of content with that field, but is rather counting the number of items in the field. This resulted in a count of 1 for each urgency even if there was multiple change requests with one of the urgencies.
Second Attempt: Using aggregation settings
For the duplicate labels, I set the aggregation type to "Group results together" and set the Group Column to "Value". My thoughts were that it would group the duplicate values together but this didn't do anything.
For the counts being separate for the duplicate values, I set the aggregation type to "Count" but this didn't seem to do anything. I also attempted "Count Distinct". I also attempted to use grouping settings.
- Drupal 10
- Module: https://www.drupal.org/project/charts
- I'm using Charts with views integration, not programmatically
- I read Charts documentation but it is limited and doesn't touch on aggregation
- I looked for aggregation documentation but I couldn't find anything that helped
- Charting Library: Highcharts