|
|
@ -285,7 +285,8 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
(this.legendConfig.showMin === true || |
|
|
(this.legendConfig.showMin === true || |
|
|
this.legendConfig.showMax === true || |
|
|
this.legendConfig.showMax === true || |
|
|
this.legendConfig.showAvg === true || |
|
|
this.legendConfig.showAvg === true || |
|
|
this.legendConfig.showTotal === true); |
|
|
this.legendConfig.showTotal === true || |
|
|
|
|
|
this.legendConfig.showLatest === true); |
|
|
this.initDataSubscription().subscribe(() => { |
|
|
this.initDataSubscription().subscribe(() => { |
|
|
subscriptionSubject.next(this); |
|
|
subscriptionSubject.next(this); |
|
|
subscriptionSubject.complete(); |
|
|
subscriptionSubject.complete(); |
|
|
@ -1295,6 +1296,7 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
max: null, |
|
|
max: null, |
|
|
avg: null, |
|
|
avg: null, |
|
|
total: null, |
|
|
total: null, |
|
|
|
|
|
latest: null, |
|
|
hidden: false |
|
|
hidden: false |
|
|
}; |
|
|
}; |
|
|
this.legendData.data.push(legendKeyData); |
|
|
this.legendData.data.push(legendKeyData); |
|
|
@ -1526,6 +1528,9 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
if (this.legendConfig.showTotal) { |
|
|
if (this.legendConfig.showTotal) { |
|
|
legendKeyData.total = this.ctx.widgetUtils.formatValue(calculateTotal(data), decimals, units); |
|
|
legendKeyData.total = this.ctx.widgetUtils.formatValue(calculateTotal(data), decimals, units); |
|
|
} |
|
|
} |
|
|
|
|
|
if (this.legendConfig.showLatest) { |
|
|
|
|
|
legendKeyData.latest = this.ctx.widgetUtils.formatValue(calculateLatest(data), decimals, units); |
|
|
|
|
|
} |
|
|
this.callbacks.legendDataUpdated(this, detectChanges !== false); |
|
|
this.callbacks.legendDataUpdated(this, detectChanges !== false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1598,3 +1603,11 @@ function calculateTotal(data: DataSet): number { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function calculateLatest(data: DataSet): number { |
|
|
|
|
|
if (data.length > 0) { |
|
|
|
|
|
return Number(data[data.length - 1][1]); |
|
|
|
|
|
} else { |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|