AbstractWidget

AbstractWidget is a base class that provides common functionality and helper methods for defining widgets, it can be extended by concrete widget classes that implement specific UI elements (e.g. charts, tables, diagrams).

Here is an example of how to inherit from the AbstractWidget class.

class MyCustomWidget extends AbstractWidget {
    
    constructor(config) {
        super(config);
    }

    onInit(context) {
        return super.onInit(context).then(function () {
            // do initialization stuff            
        }).catch(error => {
            // handle error            
        });
    }

    onDestroy(context) {
       super.onDestroy();
       // dispose allocated resources
    }
}

You can find more details about how to define widgets into this article.

By extending the abstract widget class you can leverage these methods:

addPeriodPicker(container, options, callback, context)

Create a period picker embedded in the widget.
For more details refer to createPeriodPicker(ā€¦)  method in the App Utils class.

hideMessage()

Hides the displayed message added by the showMessage or showError  methods.

loadMetricDefinitions(context, resolve, reject)

Enriches the template metrics, accessible in the Context.metrics object, with the referenced metric definitions.
This can be helpful, in case you need to display data by using metric information not present in the template (e.g. dictionary, ranges).

setLoaderVisible(visible)

Shows or hides the overlay spinner during asynchronous data loading according to the visible flag.

showError(error)

Displays an error message (e.g. Unable to load data).

showMessage(text, severity)

Displays a text message with a colored badge with a certain severity (info, warning, danger).

showNoDataAvailable()

Displays the No data available message.