Skip to content

Commit dddbc26

Browse files
palbizuPatricio Albizu
andauthored
feat: adding template tooltip (#1469)
* feat: adding template tooltip * feat: fix comments * feat: add htTooltipContext * feat: fix lint * feat: fix comments * Update projects/observability/src/shared/components/bar-gauge/bar-gauge.component.ts * feat: adding segmentContext interface * feat: fix lintern Co-authored-by: Patricio Albizu <patricioalbizu@Patricios-MacBook-Pro.local>
1 parent 4ecfbcb commit dddbc26

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

projects/observability/src/shared/components/bar-gauge/bar-gauge.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
Input,
77
OnChanges,
88
QueryList,
9+
TemplateRef,
910
ViewChild,
1011
ViewChildren
1112
} from '@angular/core';
@@ -48,9 +49,11 @@ import {
4849
[ngClass]="{ 'hide-last-divider': this.nearMaxValue }"
4950
[style.background]="segment.color"
5051
[style.width.%]="segment.percentage"
51-
htTooltip="{{ segment.label }} : {{ segment.value | htDisplayNumber }}"
52+
[htTooltip]="segment.tooltip ?? plainTooltip"
53+
[htTooltipContext]="{ $implicit: segment }"
5254
>
5355
<div class="divider"></div>
56+
<ng-template #plainTooltip> {{ segment.label }} : {{ segment.value | htDisplayNumber }} </ng-template>
5457
</div>
5558
</div>
5659
</div>
@@ -162,12 +165,17 @@ export interface Segment {
162165
label: string;
163166
value: number;
164167
color?: string;
168+
tooltip?: string | TemplateRef<SegmentContext>;
165169
}
166170

167171
interface BarSegment extends Segment {
168172
percentage: number;
169173
}
170174

175+
export interface SegmentContext {
176+
$implicit: BarSegment;
177+
}
178+
171179
export const enum BarGaugeStyle {
172180
Regular = 'regular',
173181
Compact = 'compact',

0 commit comments

Comments
 (0)