Voting starts in March for the Drupal Association Board election.
There are a couple of options for grouping view results using Views Chart Tools. Sure, Views 3 has aggregation options built in. However, Google Chart Tools has aggregation functions as well, with some additional features to boot. Let's take a look at using grouping and aggregation in Views Chart Tools 1.x.
Create a chart outlining the total number of nodes created in a given quarter. While this may be an unrealistic example, using the aggregation and modification functions demonstrated in this example can be used for much more useful purposes. For example, a line graph demonstrating the average number of products sold per day in a given quarter. I just don't have the time or will to create and sell a few thousand products, so we'll stick with auto-generated content.
First, let's take a look at our example view configuration.
Here we have the Google Charts Dashboard style enabled along with a table chart and pie chart. In addition, we have two fields - Content: Post date and Content: Nid.
First, since our end goal is to group results by quarter, we want to group the Content: Post date column.
Step 1: Google Charts Dashboard settings
Click on the Google Charts Dashboard style settings link to view the dashboard configuration page. Here we see our dashboard's data table structure. This view is intended to help users visualize the data being input into charts and format that data appropriately.
Step 2: Set the data types
As you'll notice, our Content: Post date column is marked as a string by default. While it is possible to render the date as a string, it would not be formatted properly, so we want to mark it a date type column. Note also that the Nid column is a number, so we can set its data type to number if we want, but remember that we will be aggregating (counting) the nodes that were created later anyways - and returning a number - so that makes the data type here irrelevant.
You'll notice that setting the column as date caused the roles to disappear. This is because column roles require specific data types, but more on roles in another tutorial.
Step 3: Group the results
Next, we want to enable grouping for our Post date column. Grouping results will match all rows with the same value in this column and allow us to aggregate additional fields.
Step 4: Modify the grouped data
Now that we've grouped the data table by Post date, you'll notice that a new field appeared. This is an optional modifier function that we can apply to the grouped column. In our case, we want to group by Quarter, so we can go ahead and select that option. (Note that Views Chart Tools currently only has modifier functions for Date and Date/time type columns - please submit a feature request for specific additional modifier or aggregation functions).
Step 5: Aggregate additional columns
Finally, when grouping a data table all columns that are not grouped must be aggregated. In our case we want to count the total number of nodes created for each quarter, so we select the count aggregation function. Note that we do not aggregate the Post date column.
The final product
Finally, we should have a style options form that looks something like this:
Now we can apply the changes and view our charts.
This table uses formatting for the aggregated nid field. Formatting options are available on the same style settings form by clicking the format link next to a field. This particular table uses the Bar format which demonstrates while values are above or below a certain level.
Here's an additional line chart that was later added to the same view.