Widget Tricks - ods-analysis, quick intro

The technical documentation says :

This widget exposes the results of an analysis (as an object containing a results array and optionally an aggregations object) in a variable available in the scope. It can be used with AngularJS’s ngRepeat to simply build a table of analysis results.

Normal people would say :

Ods-analysis is the way to get the values behind a chart ! What you can do with a chart, you can do the same with ods-analysis. You get the figures, and do whatever you want in your dashboard with the results !

The syntax is different, but options and parameters are pretty similar. You have a context, an X axis, you define series, optionnaly you sort the results. To conclude, we can say that : ods-analysis is the low level widget of ods-chart, its underlying layer !

What an ods-analysis results object looks like

The ods-analysis output is a json object, containing one key results. It’s value is a json array and each item contains the x value of the analysis, and one to many series.

Compare, side-by-side the ods-chart values and the ods-analysis results. They both have the same settings (x axis, series, number of results and sort parameters)

Top 10

Like with charts, it’s conveniant to use ods-analysis to sort aggregations by the computed serie (like for example the sum or average of numerical fields). In this example, the ods-analysis results object is used to print lines of an HTML table to display the information as a table.

Min/Max, Best/Worst, Size/Length

Ods-analysis results can also be processed to get the minimum and maximum value of a serie, and also compute the length of the array. By doing so, you can get interesting information like the biggest city or smallest city in your dataset by summing the population as a serie for example.

When you analyse your domain statistics, you can compute an ods-analysis with the user ID or IP address as the X axis, and then get the length of the ods-analysis results. It then correspond to the number of different users that reached your domain.

In the following example, we get the best or worst universities, by ranking score.

Multiple aggregations at once

Instead of using several contexts filtered on several values of the same field, and then computing an ods-aggregation for each context. An ods-analysis if often the good choice to compute them all with only one API Call (it’s way faster and more efficient).

HTML/CSS Home-made chart

For specific cases, ods-analysis, combined with some advanced HTML and CSS can be a complex but smart choice for data visualizations.

In this example, a very simple bar chart is made by creating one line for each X values, the width of the bar is defined by its serie. Then, by clicking on the bar, it expends and opens a chart to have more details on the selected information.

toObject AngularJS filter

A custom AngularJS filter can help to switch from a json array to a json dict by defining the desired key contained in the array items.

The main usage is to pick specific items easily in the json object instead of iterating over each elements.