xy-chartviewer multiplot support

Signed-off-by: Juergen Kleck <j.kleck@peak-solution.de>
diff --git a/nucleus/webclient/src/main/webapp/src/app/chartviewer/components/xy-chart-data-selection-panel/xy-chart-data-selection-panel.component.html b/nucleus/webclient/src/main/webapp/src/app/chartviewer/components/xy-chart-data-selection-panel/xy-chart-data-selection-panel.component.html
index bd19b27..546c190 100644
--- a/nucleus/webclient/src/main/webapp/src/app/chartviewer/components/xy-chart-data-selection-panel/xy-chart-data-selection-panel.component.html
+++ b/nucleus/webclient/src/main/webapp/src/app/chartviewer/components/xy-chart-data-selection-panel/xy-chart-data-selection-panel.component.html
@@ -74,7 +74,7 @@
       </div>
       <p-scrollPanel [style]="{width: '100%', height: '200px'}">
         <p-table [columns]="yChannelCols" [value]="yChannelOptionsFiltered" (onRowSelect)="onYChannelClick($event)" (onRowUnselect)="onYChannelClick($event)"
-                 (onHeaderCheckboxToggle)="onSelectAllYChannels($event)" [responsive]="true">
+                 (onHeaderCheckboxToggle)="onSelectAllYChannels($event)" [responsive]="true" [(selection)]="selectedTableChannels" dataKey="id">
           <ng-template pTemplate="header" let-columns>
             <tr>
               <th style="width: 3em">
diff --git a/nucleus/webclient/src/main/webapp/src/app/chartviewer/components/xy-chart-data-selection-panel/xy-chart-data-selection-panel.component.ts b/nucleus/webclient/src/main/webapp/src/app/chartviewer/components/xy-chart-data-selection-panel/xy-chart-data-selection-panel.component.ts
index 359841c..9e3566e 100644
--- a/nucleus/webclient/src/main/webapp/src/app/chartviewer/components/xy-chart-data-selection-panel/xy-chart-data-selection-panel.component.ts
+++ b/nucleus/webclient/src/main/webapp/src/app/chartviewer/components/xy-chart-data-selection-panel/xy-chart-data-selection-panel.component.ts
@@ -27,7 +27,6 @@
 import { ChannelGroup } from '../../model/types/channelgroup.class';
 import { Channel } from '../../model/types/channel.class';
 import { QueryConfig } from '../../model/types/query-config.class';
-import { streamTranslate, TRANSLATE } from '@core/mdm-core.module';
 
 @Component({
   selector: 'mdm5-xy-chart-data-selection-panel',
@@ -43,7 +42,7 @@
   public xyMode: boolean;
 
   @Output()
-  public onSelectionChanged = new EventEmitter<ChannelSelectionRow[]>();
+  public onSelectionChanged = new EventEmitter<{ rows: ChannelSelectionRow[]; groups: ChannelGroup[] }>();
 
   // select options for channels
   public yChannelOptions: Channel[] = [];
@@ -62,6 +61,7 @@
   // !! change via setter to update cache for workarround !!
   public selectedChannelGroups: ChannelGroup[] = [];
   public selectedYChannels: Channel[] = [];
+  public selectedTableChannels: Channel[] = [];
 
   private selectionChanged = false;
 
@@ -242,6 +242,9 @@
   public onSelectedChannelGroupsChanged(event: any) {
     if (this.selectedChannelGroupsTree.length === 0) {
       this.selectedChannelGroups = [];
+      this.selectedTableChannels = [];
+      this.selectedYChannels = [];
+      this.lastYChannelSelection = [];
     } else {
       this.selectedChannelGroups = this.selectedChannelGroupsTree.map(tn => tn.data);
     }
@@ -348,7 +351,7 @@
     if (this.arrayUtil.isNotEmpty(this.selectedYChannels)) {
       this.setSelectedYChannels(this.selectedYChannels.filter(channel => this.measurement
         .find(mea => mea.hasChannel(channel.id) as boolean).hasChannel(channel.id)));
-      // this.channels.get(channelGroup.id).findIndex(c => channel.id === c.id) === -1));
+      this.selectedTableChannels = this.selectedYChannels;
     }
     this.reloadAxisSelectOptions();
     this.fireSelectionChanged();
@@ -646,7 +649,7 @@
   }
 
   private fireSelectionChanged() {
-    this.onSelectionChanged.emit(this.selectedChannelRows);
+    this.onSelectionChanged.emit({ rows: this.selectedChannelRows, groups: this.selectedChannelGroups });
   }
 
   private setSelectedYChannels(channels: Channel[]) {
diff --git a/nucleus/webclient/src/main/webapp/src/app/chartviewer/components/xy-chart-viewer/xy-chart-viewer.component.ts b/nucleus/webclient/src/main/webapp/src/app/chartviewer/components/xy-chart-viewer/xy-chart-viewer.component.ts
index e853d3c..5aa6b5e 100644
--- a/nucleus/webclient/src/main/webapp/src/app/chartviewer/components/xy-chart-viewer/xy-chart-viewer.component.ts
+++ b/nucleus/webclient/src/main/webapp/src/app/chartviewer/components/xy-chart-viewer/xy-chart-viewer.component.ts
@@ -32,6 +32,7 @@
 import { Observable } from 'rxjs';
 import { BasicChartComponent } from '../basic-chart.component';
 import 'chartjs-adapter-luxon';
+import { ChannelGroup } from '../../model/types/channelgroup.class';
 
 @Component({
   selector: 'mdm5-xy-chart-viewer',
@@ -141,11 +142,16 @@
 
   /**
    * Draws chart when data selection changes
-   * @param rows
+   * @param complex data object
    */
-  public onDataSelectionChanged(rows: ChannelSelectionRow[]) {
+  public onDataSelectionChanged(complex: any) {
+    const rows: ChannelSelectionRow[] = complex.rows;
+    const selectedGroups: ChannelGroup[] = complex.groups;
     // force change detection
     this.selectedChannelRows = [...rows];
+    if (!selectedGroups || selectedGroups.length === 0) {
+      this.assignedColors = [];
+    }
 
     this.doChart();
   }