You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2021/08/23 18:44:14 UTC

[incubator-streampipes] branch dev updated: [STREAMPIPES-411] Add option to disable trend indicator

This is an automated email from the ASF dual-hosted git repository.

riemer pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 74a7bb2  [STREAMPIPES-411] Add option to disable trend indicator
74a7bb2 is described below

commit 74a7bb25ae64b379ce67d65cb22fd16b23e6fc1b
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Mon Aug 23 20:44:07 2021 +0200

    [STREAMPIPES-411] Add option to disable trend indicator
---
 .../indicator-chart-widget-config.component.html   |  4 +++-
 .../indicator/indicator-chart-widget.component.ts  | 27 +++++++++++++++-------
 .../model/indicator-chart-widget.model.ts          |  1 +
 .../line-chart/line-chart-widget.component.ts      |  3 ++-
 4 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/ui/src/app/data-explorer/components/widgets/indicator/config/indicator-chart-widget-config.component.html b/ui/src/app/data-explorer/components/widgets/indicator/config/indicator-chart-widget-config.component.html
index 6e3e173..19aae70 100644
--- a/ui/src/app/data-explorer/components/widgets/indicator/config/indicator-chart-widget-config.component.html
+++ b/ui/src/app/data-explorer/components/widgets/indicator/config/indicator-chart-widget-config.component.html
@@ -48,7 +48,9 @@
         </mat-select>
     </mat-form-field>
 
-    <mat-form-field color="accent" fxFlex="100">
+    <mat-checkbox [(ngModel)]="currentlyConfiguredWidget.dataConfig.showDelta">Show delta indicator</mat-checkbox>
+
+    <mat-form-field color="accent" fxFlex="100" *ngIf="currentlyConfiguredWidget.dataConfig.showDelta">
         <mat-label>Delta Aggregation</mat-label>
         <mat-select [(value)]="currentlyConfiguredWidget.dataConfig.deltaAggregation" (selectionChange)="triggerDataRefresh()">
             <mat-option [value]="'MEAN'">
diff --git a/ui/src/app/data-explorer/components/widgets/indicator/indicator-chart-widget.component.ts b/ui/src/app/data-explorer/components/widgets/indicator/indicator-chart-widget.component.ts
index 55e976c..c758ee6 100644
--- a/ui/src/app/data-explorer/components/widgets/indicator/indicator-chart-widget.component.ts
+++ b/ui/src/app/data-explorer/components/widgets/indicator/indicator-chart-widget.component.ts
@@ -49,7 +49,8 @@ export class IndicatorChartWidgetComponent extends BaseDataExplorerWidget<Indica
   graph = {
     layout: {
       font: {
-        color: '#FFF'
+        color: '#FFF',
+        family: 'Roboto'
       },
       autosize: true,
       plot_bgcolor: '#fff',
@@ -83,11 +84,19 @@ export class IndicatorChartWidgetComponent extends BaseDataExplorerWidget<Indica
   }
 
   refreshData() {
-    zip(this.getQuery(this.dataExplorerWidget.dataConfig.numberAggregation),
-        this.getQuery(this.dataExplorerWidget.dataConfig.deltaAggregation))
-        .subscribe(result => {
-      this.prepareData(result[0], result[1]);
-    });
+    if (this.dataExplorerWidget.dataConfig.showDelta) {
+      this.data[0].mode = 'number+delta';
+      zip(this.getQuery(this.dataExplorerWidget.dataConfig.numberAggregation),
+          this.getQuery(this.dataExplorerWidget.dataConfig.deltaAggregation))
+          .subscribe(result => {
+            this.prepareData(result[0], result[1]);
+          });
+    } else {
+      this.data[0].mode = 'number';
+      this.getQuery(this.dataExplorerWidget.dataConfig.numberAggregation).subscribe(result => {
+        this.prepareData(result);
+      });
+    }
   }
 
   getQuery(aggregation: string): Observable<DataResult> {
@@ -98,9 +107,11 @@ export class IndicatorChartWidgetComponent extends BaseDataExplorerWidget<Indica
     this.updateAppearance();
   }
 
-  prepareData(numberResult: DataResult, deltaResult: DataResult) {
+  prepareData(numberResult: DataResult, deltaResult?: DataResult) {
     this.data[0].value = numberResult.total > 0 ? numberResult.rows[0][1] : '-';
-    this.data[0].delta.reference = numberResult.total > 0 ? deltaResult.rows[0][1] : '-';
+    if (deltaResult) {
+      this.data[0].delta.reference = numberResult.total > 0 ? deltaResult.rows[0][1] : '-';
+    }
   }
 
   updateAppearance() {
diff --git a/ui/src/app/data-explorer/components/widgets/indicator/model/indicator-chart-widget.model.ts b/ui/src/app/data-explorer/components/widgets/indicator/model/indicator-chart-widget.model.ts
index d7eeff0..d153d01 100644
--- a/ui/src/app/data-explorer/components/widgets/indicator/model/indicator-chart-widget.model.ts
+++ b/ui/src/app/data-explorer/components/widgets/indicator/model/indicator-chart-widget.model.ts
@@ -23,6 +23,7 @@ export interface IndicatorChartDataConfig {
   availableProperties: EventPropertyUnion[];
   numberAggregation: string;
   deltaAggregation: string;
+  showDelta: boolean;
 }
 
 export interface IndicatorChartWidgetModel extends DataExplorerWidgetModel {
diff --git a/ui/src/app/data-explorer/components/widgets/line-chart/line-chart-widget.component.ts b/ui/src/app/data-explorer/components/widgets/line-chart/line-chart-widget.component.ts
index f8fa446..227db6b 100644
--- a/ui/src/app/data-explorer/components/widgets/line-chart/line-chart-widget.component.ts
+++ b/ui/src/app/data-explorer/components/widgets/line-chart/line-chart-widget.component.ts
@@ -73,7 +73,8 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
 
     layout: {
       font: {
-        color: '#FFF'
+        color: '#FFF',
+        family: 'Roboto'
       },
       autosize: true,
       plot_bgcolor: '#fff',