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/07/30 07:11:23 UTC
[incubator-streampipes] 08/08: [STREAMPIPES-402] Move line chart
config to widget panel
This is an automated email from the ASF dual-hosted git repository.
riemer pushed a commit to branch STREAMPIPES-319
in repository https://gitbox.apache.org/repos/asf/incubator-streampipes.git
commit 2c4a16fac8e229029bafe23ed4d83832d80cef89
Author: Dominik Riemer <ri...@fzi.de>
AuthorDate: Fri Jul 30 09:10:58 2021 +0200
[STREAMPIPES-402] Move line chart config to widget panel
---
.../data-explorer-designer-panel.component.html | 5 +
.../widgets/base/base-data-explorer-widget.ts | 102 +------------------
.../components/widgets/base/base-widget-config.ts | 98 +++++++++++++++---
.../config/line-chart-widget-config.component.html | 63 ++++++++++++
.../line-chart-widget-config.component.scss} | 16 ---
.../config/line-chart-widget-config.component.ts | 76 ++++++++++++++
.../line-chart/line-chart-widget.component.html | 52 +---------
.../line-chart/line-chart-widget.component.ts | 110 ++++++++-------------
.../line-chart/model/line-chart-widget.model.ts | 19 +++-
ui/src/app/data-explorer/data-explorer.module.ts | 4 +
...-explorer-add-visualization-dialog.component.ts | 2 +
11 files changed, 298 insertions(+), 249 deletions(-)
diff --git a/ui/src/app/data-explorer/components/designer-panel/data-explorer-designer-panel.component.html b/ui/src/app/data-explorer/components/designer-panel/data-explorer-designer-panel.component.html
index 387235d..3142c17 100644
--- a/ui/src/app/data-explorer/components/designer-panel/data-explorer-designer-panel.component.html
+++ b/ui/src/app/data-explorer/components/designer-panel/data-explorer-designer-panel.component.html
@@ -40,6 +40,11 @@
</sp-data-explorer-table-widget-config>
</div>
+ <div *ngIf="currentlyConfiguredWidget.widgetType === 'line-chart'" class="h-100 p-0">
+ <sp-data-explorer-line-chart-widget-config [currentlyConfiguredWidget]="currentlyConfiguredWidget" [dataLakeMeasure]="dataLakeMeasure">
+
+ </sp-data-explorer-line-chart-widget-config>
+ </div>
</div>
<div *ngIf="selectedIndex == 2">
<sp-data-explorer-widget-appearance-settings
diff --git a/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.ts b/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.ts
index 3d73624..3045109 100644
--- a/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.ts
+++ b/ui/src/app/data-explorer/components/widgets/base/base-data-explorer-widget.ts
@@ -20,7 +20,8 @@ import {
Directive,
EventEmitter,
Input,
- OnChanges, OnDestroy,
+ OnChanges,
+ OnDestroy,
OnInit,
Output,
SimpleChanges
@@ -31,13 +32,9 @@ import {DateRange} from '../../../../core-model/datalake/DateRange';
import {DatalakeRestService} from '../../../../core-services/datalake/datalake-rest.service';
import {IDataViewDashboardItem} from '../../../models/dataview-dashboard.model';
import {
- DashboardWidgetModel,
DataExplorerWidgetModel,
DataLakeMeasure,
- EventProperty,
- EventPropertyPrimitive,
- EventPropertyUnion,
- EventSchema
+ EventProperty
} from "../../../../core-model/gen/streampipes-model";
import {WidgetConfigurationService} from "../../../services/widget-configuration.service";
@@ -73,6 +70,8 @@ export abstract class BaseDataExplorerWidget<T extends DataExplorerWidgetModel>
ngOnInit(): void {
this.widgetConfigurationService.configurationChangedSubject.subscribe(refreshMessage => {
+ console.log(refreshMessage);
+ console.log(this.dataExplorerWidget);
if (refreshMessage.widgetId === this.dataExplorerWidget._id) {
if (refreshMessage.refreshData) {
this.refreshData();
@@ -107,101 +106,10 @@ export abstract class BaseDataExplorerWidget<T extends DataExplorerWidgetModel>
this.updateData();
}
- getValuePropertyKeys(eventSchema: EventSchema) {
- const propertyKeys: EventPropertyUnion[] = [];
-
- eventSchema.eventProperties.forEach(p => {
- if (!(p.domainProperties.some(dp => dp === 'http://schema.org/DateTime'))) {
- propertyKeys.push(p);
- }
- });
-
- return propertyKeys;
- }
-
- getNumericProperty(eventSchema: EventSchema) {
- const propertyKeys: EventPropertyUnion[] = [];
-
- eventSchema.eventProperties.forEach(p => {
- if (!(p.domainProperties.some(dp => dp === 'http://schema.org/DateTime')) && this.isNumber(p)) {
- propertyKeys.push(p);
- }
- });
-
- return propertyKeys;
- }
-
- getDimensionProperties(eventSchema: EventSchema) {
- const result: EventPropertyUnion[] = [];
- eventSchema.eventProperties.forEach(property => {
- if (property.propertyScope === 'DIMENSION_PROPERTY') {
- result.push(property);
- }
- });
-
- return result;
- }
-
- getNonNumericProperties(eventSchema: EventSchema) {
- const result: EventPropertyUnion[] = [];
- const b = new EventPropertyPrimitive();
- b["@class"] = "org.apache.streampipes.model.schema.EventPropertyPrimitive";
- b.runtimeType = 'https://www.w3.org/2001/XMLSchema#string';
- b.runtimeName = '';
-
- result.push(b);
-
- eventSchema.eventProperties.forEach(p => {
- if (!(p.domainProperties.some(dp => dp === 'http://schema.org/DateTime')) && !this.isNumber(p)) {
- result.push(p);
- }
- });
-
-
- return result;
- }
-
- getTimestampProperty(eventSchema: EventSchema) {
- const propertyKeys: string[] = [];
-
- const result = eventSchema.eventProperties.find(p =>
- this.isTimestamp(p)
- );
-
- return result;
- }
-
- isNumber(p: EventPropertyUnion): boolean {
- if (p instanceof EventPropertyPrimitive) {
- const runtimeType = (p as EventPropertyPrimitive).runtimeType;
-
- return runtimeType === 'http://schema.org/Number' ||
- runtimeType === 'http://www.w3.org/2001/XMLSchema#float' ||
- runtimeType === 'http://www.w3.org/2001/XMLSchema#double' ||
- runtimeType === 'http://www.w3.org/2001/XMLSchema#integer' ||
- runtimeType === 'https://schema.org/Number' ||
- runtimeType === 'https://www.w3.org/2001/XMLSchema#float' ||
- runtimeType === 'https://www.w3.org/2001/XMLSchema#double' ||
- runtimeType === 'https://www.w3.org/2001/XMLSchema#integer'
- ? true : false;
- } else {
- return false;
- }
- }
-
public isTimestamp(p: EventProperty) {
return p.domainProperties.some(dp => dp === 'http://schema.org/DateTime');
}
- getRuntimeNames(properties: EventPropertyUnion[]): string[] {
- const result = [];
- properties.forEach(p => {
- result.push(p.runtimeName);
- });
-
- return result;
- }
-
public updateData() {
this.refreshData();
this.refreshView();
diff --git a/ui/src/app/data-explorer/components/widgets/base/base-widget-config.ts b/ui/src/app/data-explorer/components/widgets/base/base-widget-config.ts
index 25b4cee..c91fce9 100644
--- a/ui/src/app/data-explorer/components/widgets/base/base-widget-config.ts
+++ b/ui/src/app/data-explorer/components/widgets/base/base-widget-config.ts
@@ -16,10 +16,12 @@
*
*/
-import {Directive, Input, OnChanges} from "@angular/core";
+import {Directive, Input} from "@angular/core";
import {
- DataExplorerWidgetModel, DataLakeMeasure,
+ DataExplorerWidgetModel,
+ DataLakeMeasure,
EventProperty,
+ EventPropertyPrimitive,
EventPropertyUnion,
EventSchema
} from "../../../../core-model/gen/streampipes-model";
@@ -36,6 +38,7 @@ export abstract class BaseWidgetConfig<T extends DataExplorerWidgetModel> {
}
triggerDataRefresh() {
+ console.log(this.currentlyConfiguredWidget);
this.widgetConfigurationService.notify({widgetId: this.currentlyConfiguredWidget._id, refreshData: true, refreshView: false});
}
@@ -43,19 +46,6 @@ export abstract class BaseWidgetConfig<T extends DataExplorerWidgetModel> {
this.widgetConfigurationService.notify({widgetId: this.currentlyConfiguredWidget._id, refreshData: false, refreshView: true});
}
- getTimestampProperty(eventSchema: EventSchema) {
- const propertyKeys: string[] = [];
-
- const result = eventSchema.eventProperties.find(p =>
- this.isTimestamp(p)
- );
-
- return result;
- }
-
- public isTimestamp(p: EventProperty) {
- return p.domainProperties.some(dp => dp === 'http://schema.org/DateTime');
- }
getValuePropertyKeys(eventSchema: EventSchema) {
const propertyKeys: EventPropertyUnion[] = [];
@@ -69,6 +59,36 @@ export abstract class BaseWidgetConfig<T extends DataExplorerWidgetModel> {
return propertyKeys;
}
+ getDimensionProperties(eventSchema: EventSchema) {
+ const result: EventPropertyUnion[] = [];
+ eventSchema.eventProperties.forEach(property => {
+ if (property.propertyScope === 'DIMENSION_PROPERTY') {
+ result.push(property);
+ }
+ });
+
+ return result;
+ }
+
+ getNonNumericProperties(eventSchema: EventSchema): EventPropertyUnion[] {
+ const result: EventPropertyUnion[] = [];
+ const b = new EventPropertyPrimitive();
+ b["@class"] = "org.apache.streampipes.model.schema.EventPropertyPrimitive";
+ b.runtimeType = 'https://www.w3.org/2001/XMLSchema#string';
+ b.runtimeName = '';
+
+ result.push(b);
+
+ eventSchema.eventProperties.forEach(p => {
+ if (!(p.domainProperties.some(dp => dp === 'http://schema.org/DateTime')) && !this.isNumber(p)) {
+ result.push(p);
+ }
+ });
+
+
+ return result;
+ }
+
getRuntimeNames(properties: EventPropertyUnion[]): string[] {
const result = [];
properties.forEach(p => {
@@ -77,4 +97,52 @@ export abstract class BaseWidgetConfig<T extends DataExplorerWidgetModel> {
return result;
}
+
+ getNumericProperty(eventSchema: EventSchema) {
+ const propertyKeys: EventPropertyUnion[] = [];
+
+ eventSchema.eventProperties.forEach(p => {
+ if (!(p.domainProperties.some(dp => dp === 'http://schema.org/DateTime')) && this.isNumber(p)) {
+ propertyKeys.push(p);
+ }
+ });
+
+ return propertyKeys;
+ }
+
+
+
+ getTimestampProperty(eventSchema: EventSchema) {
+ const propertyKeys: string[] = [];
+
+ const result = eventSchema.eventProperties.find(p =>
+ this.isTimestamp(p)
+ );
+
+ return result;
+ }
+
+ isNumber(p: EventPropertyUnion): boolean {
+ if (p instanceof EventPropertyPrimitive) {
+ const runtimeType = (p as EventPropertyPrimitive).runtimeType;
+
+ return runtimeType === 'http://schema.org/Number' ||
+ runtimeType === 'http://www.w3.org/2001/XMLSchema#float' ||
+ runtimeType === 'http://www.w3.org/2001/XMLSchema#double' ||
+ runtimeType === 'http://www.w3.org/2001/XMLSchema#integer' ||
+ runtimeType === 'https://schema.org/Number' ||
+ runtimeType === 'https://www.w3.org/2001/XMLSchema#float' ||
+ runtimeType === 'https://www.w3.org/2001/XMLSchema#double' ||
+ runtimeType === 'https://www.w3.org/2001/XMLSchema#integer'
+ ? true : false;
+ } else {
+ return false;
+ }
+ }
+
+ public isTimestamp(p: EventProperty) {
+ return p.domainProperties.some(dp => dp === 'http://schema.org/DateTime');
+ }
+
+
}
diff --git a/ui/src/app/data-explorer/components/widgets/line-chart/config/line-chart-widget-config.component.html b/ui/src/app/data-explorer/components/widgets/line-chart/config/line-chart-widget-config.component.html
new file mode 100644
index 0000000..81b48a2
--- /dev/null
+++ b/ui/src/app/data-explorer/components/widgets/line-chart/config/line-chart-widget-config.component.html
@@ -0,0 +1,63 @@
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ ~
+ -->
+
+<div fxFlex="100" fxLayout="column" class="ml-0 mr-0">
+ <sp-select-properties
+ label="Select Properties"
+ multiple=true
+ class="mr-10"
+ (changeSelectedProperties)="setSelectedProperties($event)"
+ [availableProperties]="currentlyConfiguredWidget.dataConfig.availableProperties"
+ [selectedProperties]="currentlyConfiguredWidget.dataConfig.selectedLineChartProperties">
+ </sp-select-properties>
+
+ <sp-select-properties
+ label="Select Background Color"
+ multiple=false
+ class="mr-10"
+ *ngIf="currentlyConfiguredWidget.dataConfig.showBackgroundColorProperty"
+ (changeSelectedProperties)="setSelectedBackgroundColorProperty($event)"
+ [availableProperties]="currentlyConfiguredWidget.dataConfig.availableNonNumericColumns"
+ [selectedProperties]="currentlyConfiguredWidget.dataConfig.selectedBackgroundColorProperty">
+ </sp-select-properties>
+ <sp-aggregate-configuration
+ *ngIf="currentlyConfiguredWidget.dataConfig.advancedSettingsActive"
+ [(aggregationValue)]="currentlyConfiguredWidget.dataConfig.aggregationValue"
+ [(aggregationTimeUnit)]="currentlyConfiguredWidget.dataConfig.aggregationTimeUnit">
+ </sp-aggregate-configuration>
+
+ <sp-group-configuration
+ [dimensionProperties]="currentlyConfiguredWidget.dataConfig.dimensionProperties"
+ *ngIf="currentlyConfiguredWidget.dataConfig.advancedSettingsActive"
+ [(groupValue)]="currentlyConfiguredWidget.dataConfig.groupValue"
+ [(showCountValue)]="currentlyConfiguredWidget.dataConfig.showCountValue">
+ </sp-group-configuration>
+ <button
+ *ngIf="currentlyConfiguredWidget.dataConfig.advancedSettingsActive"
+ (click)="triggerDataRefresh()" mat-button mat-icon-button color="primary">
+ <mat-icon>autorenew</mat-icon>
+ </button>
+ <div>
+ <mat-slide-toggle color="primary" [(ngModel)]="currentlyConfiguredWidget.dataConfig.advancedSettingsActive"
+ (change)="handlingAdvancedToggleChange()">Aggregate
+ </mat-slide-toggle>
+ </div>
+
+ <mat-slide-toggle color="primary" [(ngModel)]="currentlyConfiguredWidget.dataConfig.labelingModeOn" (change)="toggleLabelingMode()">Label
+ </mat-slide-toggle>
+</div>
diff --git a/ui/src/app/data-explorer/components/widgets/line-chart/model/line-chart-widget.model.ts b/ui/src/app/data-explorer/components/widgets/line-chart/config/line-chart-widget-config.component.scss
similarity index 66%
copy from ui/src/app/data-explorer/components/widgets/line-chart/model/line-chart-widget.model.ts
copy to ui/src/app/data-explorer/components/widgets/line-chart/config/line-chart-widget-config.component.scss
index 77f85aa..13cbc4a 100644
--- a/ui/src/app/data-explorer/components/widgets/line-chart/model/line-chart-widget.model.ts
+++ b/ui/src/app/data-explorer/components/widgets/line-chart/config/line-chart-widget-config.component.scss
@@ -15,19 +15,3 @@
* limitations under the License.
*
*/
-
-import {
- DataExplorerWidgetModel,
- EventPropertyUnion
-} from "../../../../../core-model/gen/streampipes-model";
-
-export interface LineChartDataConfig {
- availableColumns: Array<EventPropertyUnion>;
- selectedColumns: Array<EventPropertyUnion>;
- searchValue: string;
- columnNames: Array<string>;
-}
-
-export interface LineChartWidgetModel extends DataExplorerWidgetModel {
- dataConfig: LineChartDataConfig;
-}
diff --git a/ui/src/app/data-explorer/components/widgets/line-chart/config/line-chart-widget-config.component.ts b/ui/src/app/data-explorer/components/widgets/line-chart/config/line-chart-widget-config.component.ts
new file mode 100644
index 0000000..e182213
--- /dev/null
+++ b/ui/src/app/data-explorer/components/widgets/line-chart/config/line-chart-widget-config.component.ts
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+import {Component, OnInit} from '@angular/core';
+import {BaseWidgetConfig} from "../../base/base-widget-config";
+import {LineChartWidgetModel} from "../model/line-chart-widget.model";
+import {WidgetConfigurationService} from "../../../../services/widget-configuration.service";
+import {EventPropertyUnion} from "../../../../../core-model/gen/streampipes-model";
+
+@Component({
+ selector: 'sp-data-explorer-line-chart-widget-config',
+ templateUrl: './line-chart-widget-config.component.html',
+ styleUrls: ['./line-chart-widget-config.component.scss']
+})
+export class LineChartWidgetConfigComponent extends BaseWidgetConfig<LineChartWidgetModel> implements OnInit {
+
+ constructor(widgetConfigurationService: WidgetConfigurationService) {
+ super(widgetConfigurationService);
+ }
+
+ ngOnInit(): void {
+ if (!this.currentlyConfiguredWidget.dataConfig.availableProperties) {
+ this.currentlyConfiguredWidget.dataConfig.availableProperties = this.getNumericProperty(this.dataLakeMeasure.eventSchema);
+ this.currentlyConfiguredWidget.dataConfig.dimensionProperties = this.getDimensionProperties(this.dataLakeMeasure.eventSchema);
+ this.currentlyConfiguredWidget.dataConfig.availableNonNumericColumns = this.getNonNumericProperties(this.dataLakeMeasure.eventSchema);
+ this.currentlyConfiguredWidget.dataConfig.yKeys = [];
+
+ // Reduce selected columns when more then 6
+ this.currentlyConfiguredWidget.dataConfig.selectedLineChartProperties = this.currentlyConfiguredWidget.dataConfig.availableProperties.length > 6 ? this.currentlyConfiguredWidget.dataConfig.availableProperties.slice(0, 5) : this.currentlyConfiguredWidget.dataConfig.availableProperties;
+ this.currentlyConfiguredWidget.dataConfig.xKey = this.getTimestampProperty(this.dataLakeMeasure.eventSchema).runtimeName;
+ this.currentlyConfiguredWidget.dataConfig.yKeys = this.getRuntimeNames(this.currentlyConfiguredWidget.dataConfig.selectedLineChartProperties);
+ }
+ }
+
+ setSelectedProperties(selectedColumns: EventPropertyUnion[]) {
+ this.currentlyConfiguredWidget.dataConfig.selectedLineChartProperties = selectedColumns;
+ this.currentlyConfiguredWidget.dataConfig.yKeys = this.getRuntimeNames(selectedColumns);
+ this.triggerDataRefresh();
+ }
+
+ setSelectedBackgroundColorProperty(selectedBackgroundColorProperty: EventPropertyUnion) {
+ if (selectedBackgroundColorProperty.runtimeName === '') {
+ this.currentlyConfiguredWidget.dataConfig.selectedBackgroundColorProperty = undefined;
+ this.currentlyConfiguredWidget.dataConfig.backgroundColorPropertyKey = undefined;
+ } else {
+ this.currentlyConfiguredWidget.dataConfig.selectedBackgroundColorProperty = selectedBackgroundColorProperty;
+ this.currentlyConfiguredWidget.dataConfig.backgroundColorPropertyKey = selectedBackgroundColorProperty.runtimeName;
+ }
+ this.triggerDataRefresh();
+ }
+
+ handlingAdvancedToggleChange() {
+ this.currentlyConfiguredWidget.dataConfig.showBackgroundColorProperty = !this.currentlyConfiguredWidget.dataConfig.showBackgroundColorProperty;
+ this.triggerDataRefresh();
+ }
+
+ toggleLabelingMode() {
+ //this.triggerViewRefresh();
+ }
+
+}
diff --git a/ui/src/app/data-explorer/components/widgets/line-chart/line-chart-widget.component.html b/ui/src/app/data-explorer/components/widgets/line-chart/line-chart-widget.component.html
index a00c386..367d6fe 100644
--- a/ui/src/app/data-explorer/components/widgets/line-chart/line-chart-widget.component.html
+++ b/ui/src/app/data-explorer/components/widgets/line-chart/line-chart-widget.component.html
@@ -17,66 +17,18 @@
-->
<div class="widget-content">
- <div class="widget-inner-options ml-0 mr-0 mt-0">
- <div fxFlex="100" fxLayout="row">
- <div fxFlex="100" fxLayout="row" fxLayoutAlign="start center" class="ml-0 mr-0">
- <sp-select-properties
- label="Select Properties"
- multiple = true
- class="mr-10"
- (changeSelectedProperties)="setSelectedProperties($event)"
- [availableProperties]="availableProperties"
- [selectedProperties]="selectedLineChartProperties">
- </sp-select-properties>
-
- <sp-select-properties
- label="Select Background Color"
- multiple = false
- class="mr-10"
- *ngIf="showBackgroundColorProperty"
- (changeSelectedProperties)="setSelectedBackgroundColorProperty($event)"
- [availableProperties]="availableNoneNumericColumns"
- [selectedProperties]="selectedBackgroundColorProperty">
- </sp-select-properties>
- <sp-aggregate-configuration
- *ngIf="advancedSettingsActive"
- [(aggregationValue)]="aggregationValue"
- [(aggregationTimeUnit)]="aggregationTimeUnit">
- </sp-aggregate-configuration>
-
- <sp-group-configuration
- [dimensionProperties]="dimensionProperties"
- *ngIf="advancedSettingsActive"
- [(groupValue)]="groupValue"
- [(showCountValue)]="showCountValue">
- </sp-group-configuration>
- <button
- *ngIf="advancedSettingsActive"
- (click)="updateData()" mat-button mat-icon-button color="primary">
- <mat-icon>autorenew</mat-icon>
- </button>
- <div >
- <mat-slide-toggle color="primary" [(ngModel)]="advancedSettingsActive" (change)="handlingAdvancedToggleChange()">Aggregate</mat-slide-toggle>
- </div>
- </div>
-
- <div fxFlex fxLayoutAlign="end center">
- <mat-slide-toggle color="primary" [(ngModel)]="labelingModeOn" (change)="toggleLabelingMode()">Label</mat-slide-toggle>
- </div>
- </div>
- </div>
<div class="widget-inner-content h-100 overflow-y-hidden">
<sp-load-data-spinner *ngIf="showIsLoadingData"></sp-load-data-spinner>
<sp-no-data-in-date-range *ngIf="showNoDataInDateRange" [viewDateRange]="viewDateRange"></sp-no-data-in-date-range>
- <sp-select-label *ngIf="labelingModeOn"
+ <sp-select-label *ngIf="dataExplorerWidget.dataConfig.labelingModeOn"
[enableShortCuts]="true"
(labelChange)="handleLabelChange($event)">
</sp-select-label>
<plotly-plot *ngIf="data !== undefined && !showNoDataInDateRange && !showIsLoadingData"
class="plotly-container"
- [class.labeling-active]="labelingModeOn"
+ [class.labeling-active]="dataExplorerWidget.dataConfig.labelingModeOn"
[data]="data"
[layout]="graph.layout"
[config]="graph.config"
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 962f909..5e0ed2b 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
@@ -16,16 +16,16 @@
*
*/
-import { Component, OnInit, Renderer2 } from '@angular/core';
-import { MatDialog } from '@angular/material/dialog';
-import { DataResult } from '../../../../core-model/datalake/DataResult';
-import { GroupedDataResult } from '../../../../core-model/datalake/GroupedDataResult';
-import { DatalakeRestService } from '../../../../core-services/datalake/datalake-rest.service';
-import { ColorService } from './services/color.service';
-import { BaseDataExplorerWidget } from '../base/base-data-explorer-widget';
-import { EventPropertyUnion, Label } from '../../../../core-model/gen/streampipes-model';
-import { ResizeService } from '../../../services/resize.service';
-import { LabelService } from '../../../../core-ui/labels/services/label.service';
+import {Component, OnInit, Renderer2} from '@angular/core';
+import {MatDialog} from '@angular/material/dialog';
+import {DataResult} from '../../../../core-model/datalake/DataResult';
+import {GroupedDataResult} from '../../../../core-model/datalake/GroupedDataResult';
+import {DatalakeRestService} from '../../../../core-services/datalake/datalake-rest.service';
+import {ColorService} from './services/color.service';
+import {BaseDataExplorerWidget} from '../base/base-data-explorer-widget';
+import {Label} from '../../../../core-model/gen/streampipes-model';
+import {ResizeService} from '../../../services/resize.service';
+import {LabelService} from '../../../../core-ui/labels/services/label.service';
import {LineChartWidgetModel} from "./model/line-chart-widget.model";
import {WidgetConfigurationService} from "../../../services/widget-configuration.service";
@@ -38,14 +38,14 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
data: any[] = undefined;
colorPropertyStringValues: any[] = undefined;
- availableProperties: EventPropertyUnion[] = [];
- availableNoneNumericColumns: EventPropertyUnion[] = [];
- selectedLineChartProperties: EventPropertyUnion[] = [];
- selectedBackgroundColorProperty: EventPropertyUnion = undefined;
- dimensionProperties: EventPropertyUnion[] = [];
-
- yKeys: string[] = [];
- xKey: string;
+ //availableProperties: EventPropertyUnion[] = [];
+ //availableNoneNumericColumns: EventPropertyUnion[] = [];
+ //selectedLineChartProperties: EventPropertyUnion[] = [];
+ //selectedBackgroundColorProperty: EventPropertyUnion = undefined;
+ //dimensionProperties: EventPropertyUnion[] = [];
+
+ //yKeys: string[] = [];
+ //xKey: string;
private backgroundColorPropertyKey: string = undefined;
advancedSettingsActive = false;
@@ -57,10 +57,10 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
selectedLabel;
- aggregationValue = 1;
- aggregationTimeUnit = 's';
- groupValue = 'None';
- showCountValue = false;
+ //aggregationValue = 1;
+ //aggregationTimeUnit = 's';
+ //groupValue = 'None';
+ //showCountValue = false;
// this can be set to scale the line chart according to the layout
offsetRightLineChart = 10;
@@ -77,7 +77,7 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
}
// indicator variable if labeling mode is activated
- labelingModeOn = false;
+ //labelingModeOn = false;
updatemenus = [
{
@@ -144,14 +144,7 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
ngOnInit(): void {
- this.availableProperties = this.getNumericProperty(this.dataLakeMeasure.eventSchema);
- this.dimensionProperties = this.getDimensionProperties(this.dataLakeMeasure.eventSchema);
- this.availableNoneNumericColumns = this.getNonNumericProperties(this.dataLakeMeasure.eventSchema);
-
- // Reduce selected columns when more then 6
- this.selectedLineChartProperties = this.availableProperties.length > 6 ? this.availableProperties.slice(0, 5) : this.availableProperties;
- this.xKey = this.getTimestampProperty(this.dataLakeMeasure.eventSchema).runtimeName;
- this.yKeys = this.getRuntimeNames(this.selectedLineChartProperties);
+ super.ngOnInit();
this.updateData();
this.resizeService.resizeSubject.subscribe(info => {
if (info.gridsterItem.id === this.gridsterItem.id) {
@@ -169,10 +162,10 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
this.setShownComponents(true, false, false);
} else {
res.measureName = this.dataLakeMeasure.measureName;
- const tmp = this.transformData(res, this.xKey);
- this.data = this.displayData(tmp, this.yKeys);
+ const tmp = this.transformData(res, this.dataExplorerWidget.dataConfig.xKey);
+ this.data = this.displayData(tmp, this.dataExplorerWidget.dataConfig.yKeys);
- if (this.labelingModeOn) {
+ if (this.dataExplorerWidget.dataConfig.labelingModeOn) {
this.backgroundColorPropertyKey = 'sp_internal_label';
}
this.colorPropertyStringValues = this.loadBackgroundColor(tmp, this.backgroundColorPropertyKey);
@@ -187,7 +180,7 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
if (res.total === 0) {
this.setShownComponents(true, false, false);
} else {
- const tmp = this.transformGroupedData(res, this.xKey);
+ const tmp = this.transformGroupedData(res, this.dataExplorerWidget.dataConfig.xKey);
this.data = this.displayGroupedData(tmp);
if (this.data !== undefined &&
@@ -200,9 +193,10 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
}
displayData(transformedData: DataResult, yKeys: string[]) {
- if (this.yKeys.length > 0) {
+ console.log(this.dataExplorerWidget);
+ if (this.dataExplorerWidget.dataConfig.yKeys.length > 0) {
const tmp = [];
- this.yKeys.forEach(key => {
+ this.dataExplorerWidget.dataConfig.yKeys.forEach(key => {
transformedData.rows.forEach(serie => {
if (serie.name === key) {
tmp.push(serie);
@@ -243,7 +237,7 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
const newColorPropertyStringValues = [];
if (colorPropertyStringValues !== undefined && colorPropertyStringValues.length !== 0) {
for (const c of colorPropertyStringValues) {
- if (this.labelingModeOn) {
+ if (this.dataExplorerWidget.dataConfig.labelingModeOn) {
if (c === '') {
newColorPropertyStringValues.push(c);
} else {
@@ -257,7 +251,7 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
// define the function that defines the colors
let colorFunction;
- if (this.labelingModeOn) {
+ if (this.dataExplorerWidget.dataConfig.labelingModeOn) {
colorFunction = ((id) => {
if (id === '') {
return '#FFFFFF';
@@ -295,7 +289,7 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
const groupNames = Object.keys(transformedData.dataResults);
for (const groupName of groupNames) {
const value = transformedData.dataResults[groupName];
- this.yKeys.forEach(key => {
+ this.dataExplorerWidget.dataConfig.yKeys.forEach(key => {
value.rows.forEach(serie => {
if (serie.name === key) {
serie.name = groupName + ' ' + serie.name;
@@ -304,7 +298,7 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
});
});
- if (this.showCountValue) {
+ if (this.dataExplorerWidget.dataConfig.showCountValue) {
let containsCount = false;
value.rows.forEach(serie => {
if (serie.name.startsWith('count') && !containsCount) {
@@ -335,7 +329,7 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
});
// Get key of timestamp column for x axis
- const indexXkey = data.headers.findIndex(headerName => headerName === this.xKey);
+ const indexXkey = data.headers.findIndex(headerName => headerName === this.dataExplorerWidget.dataConfig.xKey);
const tmpLineChartTraces: any[] = [];
@@ -379,22 +373,7 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
return data;
}
- setSelectedProperties(selectedColumns: EventPropertyUnion[]) {
- this.selectedLineChartProperties = selectedColumns;
- this.yKeys = this.getRuntimeNames(selectedColumns);
- this.updateData();
- }
- setSelectedBackgroundColorProperty(selectedBackgroundColorProperty: EventPropertyUnion) {
- if (selectedBackgroundColorProperty.runtimeName === '') {
- this.selectedBackgroundColorProperty = undefined;
- this.backgroundColorPropertyKey = undefined;
- } else {
- this.selectedBackgroundColorProperty = selectedBackgroundColorProperty;
- this.backgroundColorPropertyKey = selectedBackgroundColorProperty.runtimeName;
- }
- this.updateData();
- }
changeLabelOfArea($event) {
const selected = $event.points[0];
@@ -471,14 +450,14 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
}
toggleLabelingMode() {
- if (this.labelingModeOn) {
+ if (this.dataExplorerWidget.dataConfig.labelingModeOn) {
for (let i = 0; i < this.data.length; i++) {
this.data[i]['mode'] = 'lines+markers';
}
this.activateLabelingMode();
this.offsetRightLineChart = 150;
} else {
- this.labelingModeOn = false;
+ this.dataExplorerWidget.dataConfig.labelingModeOn = false;
this.offsetRightLineChart = 10;
this.deactivateLabelingMode();
}
@@ -538,7 +517,7 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
const startdate = new Date(start_X).getTime() - 1;
const enddate = new Date(end_X).getTime() + 1;
- this.dataLakeRestService.saveLabelsInDatabase(this.data['measureName'], 'sp_internal_label', startdate, enddate, label, this.xKey).subscribe(
+ this.dataLakeRestService.saveLabelsInDatabase(this.data['measureName'], 'sp_internal_label', startdate, enddate, label, this.dataExplorerWidget.dataConfig.xKey).subscribe(
res => {
// TODO add pop up similar to images
// console.log('Successfully wrote label ' + currentLabel + ' into database.');
@@ -641,11 +620,6 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
return shape;
}
- handlingAdvancedToggleChange() {
- this.showBackgroundColorProperty = !this.showBackgroundColorProperty;
- this.updateData();
- }
-
setStartX(startX: string) {
this.selectedStartX = startX;
}
@@ -659,6 +633,7 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
}
refreshData() {
+ console.log("refreshing");
this.graph.layout.shapes = [];
if (!this.advancedSettingsActive) {
this.setShownComponents(false, false, true);
@@ -668,11 +643,11 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
this.processNoneGroupedData(res);
});
} else {
- if (this.groupValue === 'None') {
+ if (this.dataExplorerWidget.dataConfig.groupValue === 'None') {
this.setShownComponents(false, false, true);
this.dataLakeRestService.getData(
this.dataLakeMeasure.measureName, this.viewDateRange.startDate.getTime(), this.viewDateRange.endDate.getTime()
- , this.aggregationTimeUnit, this.aggregationValue)
+ , this.dataExplorerWidget.dataConfig.aggregationTimeUnit, this.dataExplorerWidget.dataConfig.aggregationValue)
.subscribe((res: DataResult) => {
this.processNoneGroupedData(res);
});
@@ -688,5 +663,6 @@ export class LineChartWidgetComponent extends BaseDataExplorerWidget<LineChartWi
}
refreshView() {
+ //this.toggleLabelingMode();
}
}
diff --git a/ui/src/app/data-explorer/components/widgets/line-chart/model/line-chart-widget.model.ts b/ui/src/app/data-explorer/components/widgets/line-chart/model/line-chart-widget.model.ts
index 77f85aa..565dc4e 100644
--- a/ui/src/app/data-explorer/components/widgets/line-chart/model/line-chart-widget.model.ts
+++ b/ui/src/app/data-explorer/components/widgets/line-chart/model/line-chart-widget.model.ts
@@ -22,10 +22,21 @@ import {
} from "../../../../../core-model/gen/streampipes-model";
export interface LineChartDataConfig {
- availableColumns: Array<EventPropertyUnion>;
- selectedColumns: Array<EventPropertyUnion>;
- searchValue: string;
- columnNames: Array<string>;
+ selectedLineChartProperties: Array<EventPropertyUnion>;
+ availableProperties: Array<EventPropertyUnion>;
+ dimensionProperties: Array<EventPropertyUnion>;
+ selectedBackgroundColorProperty: EventPropertyUnion;
+ availableNonNumericColumns: Array<EventPropertyUnion>;
+ advancedSettingsActive: boolean;
+ aggregationValue: number;
+ aggregationTimeUnit: string;
+ groupValue: string;
+ showCountValue: boolean;
+ showBackgroundColorProperty: boolean;
+ yKeys: string[];
+ xKey: string;
+ backgroundColorPropertyKey: string;
+ labelingModeOn: boolean;
}
export interface LineChartWidgetModel extends DataExplorerWidgetModel {
diff --git a/ui/src/app/data-explorer/data-explorer.module.ts b/ui/src/app/data-explorer/data-explorer.module.ts
index fd29bc6..5ac8615 100644
--- a/ui/src/app/data-explorer/data-explorer.module.ts
+++ b/ui/src/app/data-explorer/data-explorer.module.ts
@@ -72,6 +72,8 @@ import {TableWidgetConfigComponent} from "./components/widgets/table/config/tabl
import {DataExplorerWidgetAppearanceSettingsComponent} from "./components/designer-panel/appearance-settings/data-explorer-widget-appearance-settings.component";
import {DataExplorerWidgetDataSettingsComponent} from "./components/designer-panel/data-settings/data-explorer-widget-data-settings.component";
import {WidgetConfigurationService} from "./services/widget-configuration.service";
+import {LineChartWidgetConfigComponent} from "./components/widgets/line-chart/config/line-chart-widget-config.component";
+import {ImageWidgetConfigComponent} from "./components/widgets/image/config/image-widget-config.component";
const dashboardWidgets = [];
@@ -131,7 +133,9 @@ export const MY_NATIVE_FORMATS = {
DataExplorerWidgetDataSettingsComponent,
TableWidgetComponent,
ImageWidgetComponent,
+ ImageWidgetConfigComponent,
LineChartWidgetComponent,
+ LineChartWidgetConfigComponent,
TimeRangeSelectorComponent,
NoDataInDateRangeComponent,
LoadDataSpinnerComponent,
diff --git a/ui/src/app/data-explorer/dialogs/add-widget/data-explorer-add-visualization-dialog.component.ts b/ui/src/app/data-explorer/dialogs/add-widget/data-explorer-add-visualization-dialog.component.ts
index 7a4b7d1..08cdfc8 100644
--- a/ui/src/app/data-explorer/dialogs/add-widget/data-explorer-add-visualization-dialog.component.ts
+++ b/ui/src/app/data-explorer/dialogs/add-widget/data-explorer-add-visualization-dialog.component.ts
@@ -132,9 +132,11 @@ export class DataExplorerAddVisualizationDialogComponent implements OnInit {
// configuredWidget.eventSchema.eventProperties.push(ep.copy());
// }
+
configuredWidget.pipelineId = this.selectedDataSet.pipelineId;
configuredWidget.measureName = this.selectedDataSet.measureName;
configuredWidget.baseAppearanceConfig = {};
+ configuredWidget.baseAppearanceConfig.widgetTitle = this.selectedDataSet.measureName;
configuredWidget.visualizationConfig = {};
configuredWidget.dataConfig = {};
configuredWidget.widgetType = this.selectedWidget;