Commit ac3105510668b4fc1be27a9a959cc07ac1315111
1 parent
3f8ef73d
Add function onDirection Change for Legend
Showing
1 changed file
with
15 additions
and
0 deletions
... | ... | @@ -76,6 +76,20 @@ export class LegendConfigComponent implements OnInit, OnDestroy, ControlValueAcc |
76 | 76 | showAvg: [null, []], |
77 | 77 | showTotal: [null, []] |
78 | 78 | }); |
79 | + this.legendConfigForm.get('direction').valueChanges.subscribe((direction: LegendDirection) => { | |
80 | + this.onDirectionChanged(direction); | |
81 | + }); | |
82 | + } | |
83 | + | |
84 | + private onDirectionChanged(direction: LegendDirection) { | |
85 | + if (direction === LegendDirection.row) { | |
86 | + let position: LegendPosition = this.legendConfigForm.get('position').value; | |
87 | + if (position !== LegendPosition.bottom && position !== LegendPosition.top) { | |
88 | + position = LegendPosition.bottom; | |
89 | + } | |
90 | + this.legendConfigForm.patchValue({position}, {emitEvent: false} | |
91 | + ); | |
92 | + } | |
79 | 93 | } |
80 | 94 | |
81 | 95 | ngOnDestroy(): void { |
... | ... | @@ -125,6 +139,7 @@ export class LegendConfigComponent implements OnInit, OnDestroy, ControlValueAcc |
125 | 139 | showTotal: isDefined(this.legendSettings.showTotal) ? this.legendSettings.showTotal : false |
126 | 140 | }); |
127 | 141 | } |
142 | + this.onDirectionChanged(this.legendSettings.direction); | |
128 | 143 | this.createChangeSubscriptions(); |
129 | 144 | } |
130 | 145 | ... | ... |