Commit c27f463b89861461b447e285b503d573851f5b16
Committed by
GitHub
Merge pull request #3415 from vvlladd28/bug/sort-legend
Fixed after sort legend keys, is not correct dataKey index
Showing
3 changed files
with
11 additions
and
10 deletions
@@ -403,7 +403,7 @@ export class WidgetSubscription implements IWidgetSubscription { | @@ -403,7 +403,7 @@ export class WidgetSubscription implements IWidgetSubscription { | ||
403 | configDatasource: datasource, | 403 | configDatasource: datasource, |
404 | configDatasourceIndex: index, | 404 | configDatasourceIndex: index, |
405 | dataLoaded: (pageData, data1, datasourceIndex, pageLink) => { | 405 | dataLoaded: (pageData, data1, datasourceIndex, pageLink) => { |
406 | - this.dataLoaded(pageData, data1, datasourceIndex, pageLink, true) | 406 | + this.dataLoaded(pageData, data1, datasourceIndex, pageLink, true); |
407 | }, | 407 | }, |
408 | initialPageDataChanged: this.initialPageDataChanged.bind(this), | 408 | initialPageDataChanged: this.initialPageDataChanged.bind(this), |
409 | dataUpdated: this.dataUpdated.bind(this), | 409 | dataUpdated: this.dataUpdated.bind(this), |
@@ -575,7 +575,7 @@ export class WidgetSubscription implements IWidgetSubscription { | @@ -575,7 +575,7 @@ export class WidgetSubscription implements IWidgetSubscription { | ||
575 | 575 | ||
576 | updateDataVisibility(index: number): void { | 576 | updateDataVisibility(index: number): void { |
577 | if (this.displayLegend) { | 577 | if (this.displayLegend) { |
578 | - const hidden = this.legendData.keys[index].dataKey.hidden; | 578 | + const hidden = this.legendData.keys.find(key => key.dataIndex === index).dataKey.hidden; |
579 | if (hidden) { | 579 | if (hidden) { |
580 | this.hiddenData[index].data = this.data[index].data; | 580 | this.hiddenData[index].data = this.data[index].data; |
581 | this.data[index].data = []; | 581 | this.data[index].data = []; |
@@ -804,7 +804,7 @@ export class WidgetSubscription implements IWidgetSubscription { | @@ -804,7 +804,7 @@ export class WidgetSubscription implements IWidgetSubscription { | ||
804 | configDatasourceIndex: datasourceIndex, | 804 | configDatasourceIndex: datasourceIndex, |
805 | subscriptionTimewindow: this.subscriptionTimewindow, | 805 | subscriptionTimewindow: this.subscriptionTimewindow, |
806 | dataLoaded: (pageData, data1, datasourceIndex1, pageLink1) => { | 806 | dataLoaded: (pageData, data1, datasourceIndex1, pageLink1) => { |
807 | - this.dataLoaded(pageData, data1, datasourceIndex1, pageLink1, true) | 807 | + this.dataLoaded(pageData, data1, datasourceIndex1, pageLink1, true); |
808 | }, | 808 | }, |
809 | dataUpdated: this.dataUpdated.bind(this), | 809 | dataUpdated: this.dataUpdated.bind(this), |
810 | updateRealtimeSubscription: () => { | 810 | updateRealtimeSubscription: () => { |
@@ -1149,7 +1149,7 @@ export class WidgetSubscription implements IWidgetSubscription { | @@ -1149,7 +1149,7 @@ export class WidgetSubscription implements IWidgetSubscription { | ||
1149 | this.onSubscriptionMessage({ | 1149 | this.onSubscriptionMessage({ |
1150 | severity: 'warn', | 1150 | severity: 'warn', |
1151 | message | 1151 | message |
1152 | - }) | 1152 | + }); |
1153 | } | 1153 | } |
1154 | } | 1154 | } |
1155 | if (isUpdate) { | 1155 | if (isUpdate) { |
@@ -1274,7 +1274,7 @@ export class WidgetSubscription implements IWidgetSubscription { | @@ -1274,7 +1274,7 @@ export class WidgetSubscription implements IWidgetSubscription { | ||
1274 | const configuredDatasource = this.configuredDatasources[datasourceIndex]; | 1274 | const configuredDatasource = this.configuredDatasources[datasourceIndex]; |
1275 | const startIndex = configuredDatasource.dataKeyStartIndex; | 1275 | const startIndex = configuredDatasource.dataKeyStartIndex; |
1276 | const dataKeysCount = configuredDatasource.dataKeys.length; | 1276 | const dataKeysCount = configuredDatasource.dataKeys.length; |
1277 | - const index = startIndex + dataIndex*dataKeysCount + dataKeyIndex; | 1277 | + const index = startIndex + dataIndex * dataKeysCount + dataKeyIndex; |
1278 | let update = true; | 1278 | let update = true; |
1279 | let currentData: DataSetHolder; | 1279 | let currentData: DataSetHolder; |
1280 | if (this.displayLegend && this.legendData.keys[index].dataKey.hidden) { | 1280 | if (this.displayLegend && this.legendData.keys[index].dataKey.hidden) { |
@@ -1331,7 +1331,7 @@ export class WidgetSubscription implements IWidgetSubscription { | @@ -1331,7 +1331,7 @@ export class WidgetSubscription implements IWidgetSubscription { | ||
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | private updateLegend(dataIndex: number, data: DataSet, detectChanges: boolean) { | 1333 | private updateLegend(dataIndex: number, data: DataSet, detectChanges: boolean) { |
1334 | - const dataKey = this.legendData.keys[dataIndex].dataKey; | 1334 | + const dataKey = this.legendData.keys.find(key => key.dataIndex === dataIndex).dataKey; |
1335 | const decimals = isDefined(dataKey.decimals) ? dataKey.decimals : this.decimals; | 1335 | const decimals = isDefined(dataKey.decimals) ? dataKey.decimals : this.decimals; |
1336 | const units = dataKey.units && dataKey.units.length ? dataKey.units : this.units; | 1336 | const units = dataKey.units && dataKey.units.length ? dataKey.units : this.units; |
1337 | const legendKeyData = this.legendData.data[dataIndex]; | 1337 | const legendKeyData = this.legendData.data[dataIndex]; |
@@ -32,7 +32,7 @@ | @@ -32,7 +32,7 @@ | ||
32 | <td><span class="tb-legend-line" [ngStyle]="{backgroundColor: legendKey.dataKey.color}"></span></td> | 32 | <td><span class="tb-legend-line" [ngStyle]="{backgroundColor: legendKey.dataKey.color}"></span></td> |
33 | <td class="tb-legend-label" | 33 | <td class="tb-legend-label" |
34 | (click)="toggleHideData(legendKey.dataIndex)" | 34 | (click)="toggleHideData(legendKey.dataIndex)" |
35 | - [ngClass]="{ 'tb-hidden-label': legendData.keys[legendKey.dataIndex].dataKey.hidden, 'tb-horizontal': isHorizontal }"> | 35 | + [ngClass]="{ 'tb-hidden-label': legendKey.dataKey.hidden, 'tb-horizontal': isHorizontal }"> |
36 | {{ legendKey.dataKey.label }} | 36 | {{ legendKey.dataKey.label }} |
37 | </td> | 37 | </td> |
38 | <td class="tb-legend-value" *ngIf="legendConfig.showMin === true">{{ legendData.data[legendKey.dataIndex].min }}</td> | 38 | <td class="tb-legend-value" *ngIf="legendConfig.showMin === true">{{ legendData.data[legendKey.dataIndex].min }}</td> |
@@ -47,7 +47,7 @@ | @@ -47,7 +47,7 @@ | ||
47 | <span class="tb-legend-line" [ngStyle]="{backgroundColor: legendKey.dataKey.color}"></span> | 47 | <span class="tb-legend-line" [ngStyle]="{backgroundColor: legendKey.dataKey.color}"></span> |
48 | <span class="tb-legend-label" | 48 | <span class="tb-legend-label" |
49 | (click)="toggleHideData(legendKey.dataIndex)" | 49 | (click)="toggleHideData(legendKey.dataIndex)" |
50 | - [ngClass]="{ 'tb-hidden-label': legendData.keys[legendKey.dataIndex].dataKey.hidden}"> | 50 | + [ngClass]="{ 'tb-hidden-label': legendKey.dataKey.hidden}"> |
51 | {{ legendKey.dataKey.label }} | 51 | {{ legendKey.dataKey.label }} |
52 | </span> | 52 | </span> |
53 | </td> | 53 | </td> |
@@ -52,8 +52,9 @@ export class LegendComponent implements OnInit { | @@ -52,8 +52,9 @@ export class LegendComponent implements OnInit { | ||
52 | } | 52 | } |
53 | 53 | ||
54 | toggleHideData(index: number) { | 54 | toggleHideData(index: number) { |
55 | - if (!this.legendData.keys[index].dataKey.settings.disableDataHiding) { | ||
56 | - this.legendData.keys[index].dataKey.hidden = !this.legendData.keys[index].dataKey.hidden; | 55 | + const dataKey = this.legendData.keys.find(key => key.dataIndex === index).dataKey; |
56 | + if (!dataKey.settings.disableDataHiding) { | ||
57 | + dataKey.hidden = !dataKey.hidden; | ||
57 | this.legendKeyHiddenChange.emit(index); | 58 | this.legendKeyHiddenChange.emit(index); |
58 | } | 59 | } |
59 | } | 60 | } |