Skip to content

Conversation

skjindal93
Copy link
Contributor

@skjindal93 skjindal93 commented Jan 9, 2021

Description

  • Added extra arc of Math.PI / 12 at the bottom of the gauge component, instead of keeping it as semicircle. Adding the extra arc to the semicircle will require extra padding at the bottom, but it cannot be a fixed padding, because the larger the radius, the greater the padding required at the bottom. Approximating extra arc length as the extra padding required at the bottom
  • Gauge y origin can be optimized to radius value always
  • Reduced the arc width

Testing

Tested with various width and height for the gauge component. It works beautifully auto computing the extra space required below

Smaller radius
Screen Shot 2021-01-09 at 5 58 41 PM

Larger radius
Screen Shot 2021-01-09 at 5 59 01 PM

Checklist:

  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • Any dependent changes have been merged and published in downstream modules

@skjindal93 skjindal93 requested a review from a team as a code owner January 9, 2021 12:29
@codecov
Copy link

codecov bot commented Jan 9, 2021

Codecov Report

Merging #486 (2c15ca8) into main (5aa9a4f) will decrease coverage by 0.01%.
The diff coverage is 78.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #486      +/-   ##
==========================================
- Coverage   85.68%   85.67%   -0.02%     
==========================================
  Files         749      749              
  Lines       15321    15331      +10     
  Branches     1814     1816       +2     
==========================================
+ Hits        13128    13135       +7     
- Misses       2162     2165       +3     
  Partials       31       31              
Impacted Files Coverage Δ
...ity/src/shared/components/gauge/gauge.component.ts 90.74% <78.57%> (-4.72%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5aa9a4f...2c15ca8. Read the comment docs.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@skjindal93 skjindal93 merged commit 1aa6d77 into main Jan 10, 2021
@skjindal93 skjindal93 deleted the fix+gauge+origin branch January 10, 2021 03:44
@github-actions
Copy link

Unit Test Results

    4 files  ±0  230 suites  ±0   12m 59s ⏱️ +10s
797 tests ±0  797 ✔️ ±0  0 💤 ±0  0 ❌ ±0 
801 runs  ±0  801 ✔️ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 1aa6d77. ± Comparison against base commit 5aa9a4f.

private static readonly GAUGE_ARC_CORNER_RADIUS: number = 10;
private static readonly GAUGE_AXIS_PADDING: number = 30;
private static readonly GAUGE_MIN_RADIUS_TO_SHOW_PATH: number = 80;
private static readonly EXTRA_ARC_ANGLE: number = Math.PI / 12;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the extra arc angle added to start and end so that the label appears more inside? Instead of this, could we have done this by updating the position of text on line 30?

startAngle: -Math.PI / 2,
endAngle: -Math.PI / 2 + (inputData.value / inputData.maxValue) * Math.PI
startAngle: -Math.PI / 2 - GaugeComponent.EXTRA_ARC_ANGLE,
endAngle: -Math.PI / 2 - GaugeComponent.EXTRA_ARC_ANGLE + (inputData.value / inputData.maxValue) * Math.PI
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems incorrect to me.

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.

case 2: inputData.value = inputData.maxValue, in this case the end angle of value arc should be equal to max end angle of background arc, that is Math.PI / 2 + GaugeComponent.EXTRA_ARC_ANGLE. Line 111, would make it -Math.PI / 2 - GaugeComponent.EXTRA_ARC_ANGLE + 1 * Math.PI = Math.PI / 2 - GaugeComponent.EXTRA_ARC_ANGLE

So the value arc would never be completely full.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I will fix that

* needs to be calculated using the provided height, instead of width / 2
*/
const radius = width / 2;
const extraArcHeight = this.calculateExtraArcLength(radius);
Copy link
Contributor

Choose a reason for hiding this comment

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

If we adjust the text position, could we avoid all this additional logic due to the extra arc length?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants