Skip to content

Commit bba15af

Browse files
fix(gauge): value arc angle computation (#494)
* fix(gauge): value arc angle computation * default angle arc for value 0 in gauge * chore(gauge): change the default arc to 0.02 * revert the nub computation on 0 arc angle * fix: prettier Co-authored-by: Anand Tiwary <52081890+anandtiwary@users.noreply.github.com>
1 parent 8dc4b72 commit bba15af

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

projects/observability/src/shared/components/gauge/gauge.component.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ describe('Gauge component', () => {
5656
value: 80,
5757
maxValue: 100,
5858
valueArc:
59-
'M-137.45365478341216,36.83059579592157A7.5,7.5,0,0,1,-146.73136591755903,31.143317998687955A150,150,0,0,1,88.13185990085536,-121.37864421065183A7.5,7.5,0,0,1,89.55386161673987,-110.58980906724544L89.55386161673987,-110.58980906724544A7.5,7.5,0,0,1,79.31867391076982,-109.24077978958663A135,135,0,0,0,-132.05822932580313,28.02898619881914A7.5,7.5,0,0,1,-137.45365478341216,36.83059579592157Z',
59+
'M-137.45365478341216,36.83059579592157A7.5,7.5,0,0,1,-146.73136591755903,31.143317998687955A150,150,0,0,1,129.88160257335298,-75.03845222935763A7.5,7.5,0,0,1,126.79245119273195,-64.60398068647702L126.79245119273195,-64.60398068647702A7.5,7.5,0,0,1,116.8934423160177,-67.5346070064219A135,135,0,0,0,-132.05822932580313,28.02898619881914A7.5,7.5,0,0,1,-137.45365478341216,36.83059579592157Z',
6060
threshold: {
6161
color: '#9e4c41',
6262
end: 90,

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,13 @@ export class GaugeComponent implements OnChanges {
104104
}
105105

106106
private buildValueArc(radius: number, inputData: GaugeInputData): string {
107+
const startAngle = -(Math.PI / 2 + GaugeComponent.EXTRA_ARC_ANGLE);
108+
107109
return this.buildArcGenerator()({
108110
innerRadius: radius - GaugeComponent.GAUGE_RING_WIDTH,
109111
outerRadius: radius,
110-
startAngle: -Math.PI / 2 - GaugeComponent.EXTRA_ARC_ANGLE,
111-
endAngle: -Math.PI / 2 - GaugeComponent.EXTRA_ARC_ANGLE + (inputData.value / inputData.maxValue) * Math.PI
112+
startAngle: startAngle,
113+
endAngle: startAngle + 2 * (inputData.value / inputData.maxValue) * -startAngle
112114
})!;
113115
}
114116

0 commit comments

Comments
 (0)