Widget Tricks - ods-aggregation

The technical documentation says :

This widget exposes the results of an aggregation function over a context… The result is exposed into a new variable that you can use in other widgets or directly in your HTML.

More concretely :

It computes a function like the sum, average, minimum, maximum etc.. over a numerical field. Depending on the context parameters, if filtered (queries, refines, etc…) it will compute the aggregation on a subset of the records, if not, on the entire dataset.

A simple ods-aggregation results

Count the number of record of a dataset, here : the number of US hospitals

An ods-aggregation results with a function on a field

A multiple ods-aggregation and a computation to get a new value from the results

The same two aggregation that before, declared in the same bloc, and used in a pourcentage formula in an AngularJS expression

Evolution over past years

A multiple ods-aggregation on two different context

This example showcase the number of cities in France before and after a reform (2015 vs. 2016).

Progression bar / custom gauge

Considering that a gauge or progression bar is nothing more than displaying a value over a total value, we just need to see how to make objects grow with CSS style attributes !

Progression bar / custom gauge

A different way to do it is to play with the background color only ! the element keeps it’s full width or height, but a linear gradient style colors it until the pourcentage value.

From 0% to the pourcentage value X with a color, then from X to 100% in white.