Interactive Embedded Dashboards

With a few lines of Groovy code, it is very easy to embed a dashboard as a portlet of another dashboard. This creates an interactive dashboard which can change dynamically in reaction to an event. Clicking on a result in one portlet triggers an event, which changes the input (and therefore the content) of another, embedded portlet.

For example, you have a dashboard with a grid, which contains details about products, and a chart that graphically displays the product data. When you select a row in the grid (a particular product), you want to see the chart automatically updated so that it displays the correct data for the selected product.

In this section:

Advantages

The main reasons for using embedded dashboards are:

  • A single dashboard can be reused by embedding it within multiple main dashboards.

  • An embedded dashboard can be based on events and parameters provided by the main dashboard.

Code

Simply add a logic element that returns a DashboardApi instance:

DashboardApi example
return api.dashboard('<dashboard_name>').showEmbedded()

Of course, it is also possible to add more elements in the main dashboard.

Parameters

The main dashboard can provide input parameters to the embedded dashboard via DashboardApi.setParam(String param_name, Object param_value). The above example can be extended to:

Main Dashboard
return api .dashboard('<dashboard_name>') // Here the user can assign values to the embedded dashboard inputs .setParam('Customer Id', 'CD-00067') // ... and of course this means it could also "forward" its own inputs .setParam('Product Id', input.'Product Id') // Show the dashboard embedded ... .showEmbedded() // You will often want to hide the embedded dashboard's inputs from the end user .withInputsHidden()

The embedded dashboard can then read the parameters via the input binding variable:

Embedded Dashboard
def sku = input.'Product Id' def customer = input.'Customer Id' // these can now be used, e.g. to build a chart api.newChartBuilder().newBarLine().addSeries() .setLabel('Invoice Price p/u') .setDatamart('DM.datamart_transaction') .setCurrency('EUR') .addDimFilter('ProductID', sku) // <=== .addDimFilter('CustomerID', customer) // <=== .setAxisX('Country') .setAxisY('InvoicePrice').withPerUnit().back() .setType(SeriesType.BAR) .withSortByAxisY(SortType.ASCENDING) .back() .build()

Events

Every event has its source (e.g., a grid) and a payload – arbitrary data (e.g., values of grid columns), which are passed to the dashboard portlet. Elements which can trigger an embedded dashboard to receive new parameters are:

ResultMatrix

The ResultMatrix element can trigger an embedded dashboard to receive new parameters and be rendered again. 

The event is triggered by a row click, and withColValueAsEventDataAttr() must be called for each column for which values should be added as a payload of the event. Only single selections of grid rows are supported.

Main Dashboard - Matrix Element
Main Dashboard - Embedded Element

The embedded dashboard's logic can read the parameters as input.<param_name1>) and input.<param_name2>.

Open Embedded Dashboard on New Tab 

An embedded dashboard can be opened as a separate dashboard on a new browser tab. Parameters are passed on in the URL.

Matrix Element
Embedded Element

ScatterChart

A chart generating click events that can send parameters and refresh an embedded dashboard is the ChartBuilder's ScatterChart.

It is possible to get both the AggregationBy (i.e., GroupBy) and BandBy dimensions of the clicked point.

Main Dashboard - Chart Element
Main Dashboard - Embedded Element

The embedded dashboard's logic can read the parameters as input.<param_name1> and input.<param_name2>.

BarLineChart

Another chart that can generate click events is the ChartBuilder's BarLineChart.

The only data provided so far is the X axis category of the clicked bar.

Main Dashboard - Chart Element
Main Dashboard - Embedded Element

The embedded dashboard's logic can read the parameter as input.<param_name>.

Data Tab of any Chart (except Waterfalls)

Mainly with the DataTable chart (but also with the Data tab of any other chart type except Waterfall and WaterfallComparison), it is possible to subscribe to row level and cell level click events. The event can provide values of some or all of the dimensions shown in the grid, by calling one of these methods:

  • withAnyDimensionAsEventDataAttr() as a wildcard

  • withDimensionAsEventDataAttr(<dimName>) one or multiple times

For row click events all the requested dimensions will be provided. For cell clicks, the cell must be in the column of a subscribed dimension, and if so then only the cell's contents will be provided.

Main Dashboard - Chart Element
Main Dashboard - Embedded Element

The embedded dashboard's logic can read the parameters as input.<param_name1> and input.<param_name2>.

Dashboard Display Modes

There are three ways to display the dashboard:

  • Embedded – The dashboard is embedded in the master dashboard as another portlet/dashlet.

  • Tab – The dashboard is opened in a new tab.

  • Window – The dashboard is opened in a new popup window.

Available Dashboard API Methods

  • DashboardApi setParam(String paramName, Object value);

  • DashboardApi showEmbedded();

  • DashboardApi andRecalculateOn(String eventName);

  • DashboardApi openInTabOrRecalculateOn(String eventName);

  • DashboardApi openInModalOrRecalculateOn(String eventName);

  • DashboardApi withEventDataAttr(String attrName);

  • DashboardApi asParam(String paramName);

  • DashboardApi withInputsHidden();

For more details see the API Documentation.

Found an issue in documentation? Write to us.

 
Pricefx version 13.1