This sub-element is used to reference a statistic and display the result value(s).
Main concepts
The main concepts to know in order to use statistics correctly are described here.
Context
Statistics are implicitly bound to the underlying context, for instance, a thing-based statistic, if placed within the location dashboard, will return only the location's thing-specific data, else it will work on all things available under the navigated elements (e.g. Customer).
Resource
When configuring a statistic you need to define the target resource to use as input. You can select one of the following resources: ACTION, ALERT, CUSTOMER, LOCATION, PARTNER, THING, USER, WORK_SESSION.
resource="THING"
Alert Status
When using ALERT, you can also specify the status, which can be:
- ACTIVE: only active alerts are included in the computation.
- ACTIVATED: all alerts historical or active are included in the computation.
alertStatus="ACTIVE"
Aggregation
The statistic result can be an aggregation, one of: AVG, COUNT, MAX, MIN, SUM.
Except for COUNT, when other aggregation are used you must also specify the property to aggregate (e.g. a work session monitored metric, a thing property, the duration for alerts).
aggregation="COUNT"
Grouping
Optionally you can group the result by a property (e.g. thingDefinition.name), or in case of objects having a creation/start/activation timestamp (e.g. ALERTS), also by: DAY, MONTH, YEAR.
When you are grouping by a property, with ranges defined, the computation will use thresholds to group results.
Optionally, if you are grouping by a continuous numeric property, you can also specify the number of intervals to group results. For instance, you can count things and group them by the working hours into 10 ranges.
[groupBy]="['properties.workingHours:10']"
Querying
Each statistic support a query you can use to filter the input objects. For instance, you can count the things that are online:
[query]="[{'property': 'connectionStatus', 'predicate': 'eq', 'value': '1'}]"
Sorting
You can define whether the result must be returned in descending or ascending.
sortDirection="ASC"
If unspecified, results are returned as objects are found in the database, generally by name ascending, or by start/activation timestamp descending.
Averaged By
Statistics results whose data are related to things (e.g. work session, alert) can be averaged by the number of things involved in the computation context. For instance, you can compute the average number of alerts by thing.
averagedBy="thingCount"
Configuration
code_blocksCode View
Template Syntax
Below you can find some examples of how to use the component within a template.
<statistic resource="CUSTOMER" aggregation="COUNT"></statistic> <statistic resource="THING" aggregation="COUNT" [groupBy]="['thingDefinition.name']"></statistic> <statistic resource="ALERT" aggregation="COUNT" [groupBy]="['name']"></statistic> <statistic resource="WORK_SESSION" aggregation="SUM" [groupBy]="['name']" property="duration"></statistic>
Component Reference
Here is a comprehensive list of all the elements and properties that can be used to configure the component.
Statistic <statistic> | |
---|---|
PROPERTIES | |
Aggregation | The function used to aggregate data. Type: ENUM | Optional | Values: AVG COUNT MAX MIN SUM aggregation="MAX" |
Alert Status | Define whether to include alerts that are still active, or have been activated in a period. Type: ENUM | Optional | Values: ACTIVE ACTIVATED activationType="ACTIVATED" |
Averaged By | The count used to average the statistic results (e.g. Average alert count by thing). Type: ENUM | Optional | Values: thingCount averagedBy="thingCount" |
Group By | The property used to group results. For instance: customer.country. In the case where the underlying objects are temporally distributed you can also aggregate by HOUR, DAY, MONTH and YEAR. Type: GROUP_BY | Optional groupBy="customer.name" |
Property | The object property whose values must be aggregated. Type: PROPERTY | Optional property="PROPERTY" |
Resource | The resource from which to retrieve the items to be used to calculate the statistic. Type: ENUM | Required | Values: ACTION ALERT CUSTOMER LOCATION PARTNER THING USER WORK_SESSION resource="ALERT" |
Sorting | The sort direction used to order categories by value (default none). Type: ENUM | Optional | Values: ASC DESC sortDirection="DESC" |
Value Filter | The name of the filter used to transform and display values. Type: FILTER | Optional filter="fooBarFilter" |
Name | The statistic whose results(s) must be loaded by the widget. Type: STATISTIC | Required | Values: activeAlertCount activatedAlertCount alertCount alertCountByAlertDefinition thingCount thingPropertyAggregation locationCount customerCount userCount workSessionCount workSessionCount workSessionElapsedTime workSessionSumMetricValues name="alertCount" [DEPRECATED] Use the Resource, and select the Aggregation and Property to aggregate. |
Comments
0 comments
Please sign in to leave a comment.