-
Notifications
You must be signed in to change notification settings - Fork 11
fix(gauge): value arc angle computation #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
80748a0
1e7734f
b3f5ccc
3c46e03
f7fe917
ad17b96
20e963e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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, | ||
| endAngle: -completeAngle + 2 * Math.max(0.05, inputData.value / inputData.maxValue) * completeAngle | ||
|
||
| })!; | ||
| } | ||
|
|
||
|
|
||



There was a problem hiding this comment.
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 arcThere was a problem hiding this comment.
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
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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)Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
completeAngleto just startAngle and assign it-completeAngle?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't catch the comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CompleteAngleis confusing to me. Can we doconst startAngle = - (Math.PI / 2 + GaugeComponent.EXTRA_ARC_ANGLE);?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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)