Browse Source
Merge pull request #3627 from vvlladd28/improvement/legend-sort
UI: Added new options for legend config (sort datakeys in legend)
pull/3703/head
Igor Kulikov
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
12 additions and
5 deletions
-
ui-ngx/src/app/core/api/widget-subscription.ts
-
ui-ngx/src/app/modules/home/components/widget/legend-config-panel.component.html
-
ui-ngx/src/app/modules/home/components/widget/legend-config-panel.component.ts
-
ui-ngx/src/app/modules/home/components/widget/legend.component.ts
-
ui-ngx/src/app/shared/models/widget.models.ts
-
ui-ngx/src/assets/locale/locale.constant-en_US.json
|
|
|
@ -1226,9 +1226,6 @@ export class WidgetSubscription implements IWidgetSubscription { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
if (this.displayLegend) { |
|
|
|
this.legendData.keys = this.legendData.keys.sort((key1, key2) => key1.dataKey.label.localeCompare(key2.dataKey.label)); |
|
|
|
} |
|
|
|
if (this.caulculateLegendData) { |
|
|
|
this.data.forEach((dataSetHolder, keyIndex) => { |
|
|
|
this.updateLegend(keyIndex, dataSetHolder.data, false); |
|
|
|
|
|
|
|
@ -38,6 +38,9 @@ |
|
|
|
</mat-option> |
|
|
|
</mat-select> |
|
|
|
</mat-form-field> |
|
|
|
<mat-checkbox formControlName="sortDataKeys"> |
|
|
|
{{ 'legend.sort-legend' | translate }} |
|
|
|
</mat-checkbox> |
|
|
|
<mat-checkbox formControlName="showMin"> |
|
|
|
{{ 'legend.show-min' | translate }} |
|
|
|
</mat-checkbox> |
|
|
|
|
|
|
|
@ -68,6 +68,7 @@ export class LegendConfigPanelComponent extends PageComponent implements OnInit |
|
|
|
this.legendConfigForm = this.fb.group({ |
|
|
|
direction: [this.data.legendConfig.direction, []], |
|
|
|
position: [this.data.legendConfig.position, []], |
|
|
|
sortDataKeys: [this.data.legendConfig.sortDataKeys, []], |
|
|
|
showMin: [this.data.legendConfig.showMin, []], |
|
|
|
showMax: [this.data.legendConfig.showMax, []], |
|
|
|
showAvg: [this.data.legendConfig.showAvg, []], |
|
|
|
|
|
|
|
@ -60,8 +60,11 @@ export class LegendComponent implements OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
legendKeys(): LegendKey[] { |
|
|
|
return this.legendData.keys |
|
|
|
.filter(legendKey => this.legendData.keys[legendKey.dataIndex].dataKey.inLegend); |
|
|
|
let keys = this.legendData.keys; |
|
|
|
if (this.legendConfig.sortDataKeys) { |
|
|
|
keys = this.legendData.keys.sort((key1, key2) => key1.dataKey.label.localeCompare(key2.dataKey.label)); |
|
|
|
} |
|
|
|
return keys.filter(legendKey => this.legendData.keys[legendKey.dataIndex].dataKey.inLegend); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@ -203,6 +203,7 @@ export const legendPositionTranslationMap = new Map<LegendPosition, string>( |
|
|
|
export interface LegendConfig { |
|
|
|
position: LegendPosition; |
|
|
|
direction?: LegendDirection; |
|
|
|
sortDataKeys: boolean; |
|
|
|
showMin: boolean; |
|
|
|
showMax: boolean; |
|
|
|
showAvg: boolean; |
|
|
|
@ -213,6 +214,7 @@ export function defaultLegendConfig(wType: widgetType): LegendConfig { |
|
|
|
return { |
|
|
|
direction: LegendDirection.column, |
|
|
|
position: LegendPosition.bottom, |
|
|
|
sortDataKeys: false, |
|
|
|
showMin: false, |
|
|
|
showMax: false, |
|
|
|
showAvg: wType === widgetType.timeseries, |
|
|
|
|
|
|
|
@ -1668,6 +1668,7 @@ |
|
|
|
"legend": { |
|
|
|
"direction": "Legend direction", |
|
|
|
"position": "Legend position", |
|
|
|
"sort-legend": "Sort datakeys in legend", |
|
|
|
"show-max": "Show max value", |
|
|
|
"show-min": "Show min value", |
|
|
|
"show-avg": "Show average value", |
|
|
|
|