Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Gauge component', () => {
value: 80,
maxValue: 100,
valueArc:
'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',
'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',
threshold: {
color: '#9e4c41',
end: 90,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,13 @@ export class GaugeComponent implements OnChanges {
}

private buildValueArc(radius: number, inputData: GaugeInputData): string {
const completeAngle = Math.PI / 2 + GaugeComponent.EXTRA_ARC_ANGLE;

return this.buildArcGenerator()({
innerRadius: radius - GaugeComponent.GAUGE_RING_WIDTH,
outerRadius: radius,
startAngle: -Math.PI / 2 - GaugeComponent.EXTRA_ARC_ANGLE,
endAngle: -Math.PI / 2 - GaugeComponent.EXTRA_ARC_ANGLE + (inputData.value / inputData.maxValue) * Math.PI
startAngle: -completeAngle,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this handle the first case described in the comment? If inputData.value is 0, we're doing [-completeAngle, -completeAngle] so there'd still be no arc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We want no value arc, when the inputData.value is 0. In fact @anandtiwary mentioned that's the expected outcome as well

case 1: inputData.value = 0, the end angle would be -Math.PI / 2 - GaugeComponent.EXTRA_ARC_ANGLE which is same as start angle. So the arc will be completely empty. Expected outcome.

Copy link
Contributor

@aaron-steinfeld aaron-steinfeld Jan 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I misread his comment - I thought our ux generally has a little arc for a 0-value gauge to show it's "emptiness"? I'm pretty sure that's what we do in the linear case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. fair point. I can use a value of 0.5, if the value is 0 to display the 0-value arc

Copy link
Contributor

@aaron-steinfeld aaron-steinfeld Jan 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes sense - something like percentFill = Math.max(0.01, inputData.value / inputData.maxValue)

Copy link
Contributor

@anandtiwary anandtiwary Jan 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure it looks any better to show a little arc for 0.

Also, could we rename completeAngle to just startAngle and assign it -completeAngle ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could we rename completeAngle to just startAngle and assign it -completeAngle

Didn't catch the comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CompleteAngle is confusing to me. Can we do const startAngle = - (Math.PI / 2 + GaugeComponent.EXTRA_ARC_ANGLE); ?

Copy link
Contributor

@anandtiwary anandtiwary Jan 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, endAngle = startAngle + 2 * (inputData.value / inputData.maxValue) * (- startAngle)

endAngle: -completeAngle + 2 * Math.max(0.05, inputData.value / inputData.maxValue) * completeAngle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.05 feels high here, how does it look? It's showing a 5% fill in the empty case - I was thinking a 1% fill would be sufficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.01
Screen Shot 2021-01-11 at 9 56 20 PM

0.02
Screen Shot 2021-01-11 at 9 58 24 PM

0.05
Screen Shot 2021-01-11 at 9 56 42 PM

Copy link
Contributor Author

@skjindal93 skjindal93 Jan 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.05 looks high, as you said. Looks like a real +ve value.

0.02 seems to look good as compared to 0.01

})!;
}

Expand Down