Skip to content
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

feat(web): unify unit formatting #6978

Merged

Conversation

silkeholmebonnen
Copy link
Contributor

@silkeholmebonnen silkeholmebonnen commented Jul 12, 2024

Issue

AVO-255

Description

This PR unifies the unit formatting so that it uses the same unit when displaying a value and the total value.

Preview

Old:
image

New:
image

Old:
image

New:
image

Double check

  • I have tested my parser changes locally with poetry run test_parser "zone_key"
  • I have run pnpx prettier@2 --write . and poetry run format in the top level directory to format my changes.

@silkeholmebonnen
Copy link
Contributor Author

silkeholmebonnen commented Jul 12, 2024

I would like to hear your thoughts on the number of digits we should use and if we want to do it this way or if you can think of a better way to do it?

@madsnedergaard, @VIKTORVAV99, @tonypls and @Alportan

@silkeholmebonnen
Copy link
Contributor Author

In a case like this the number gets pretty long.
image

@VIKTORVAV99
Copy link
Member

I would like to hear your thoughts on the number of digits we should use and if we want to do it this way or if you can think of a better way to do it?

@madsnedergaard, @VIKTORVAV99, @tonypls

Hmm, that's a lot of decimals in some places. Which might be fine information wise but have we checked that it won't break the UI on smaller devices in particular?

And I'm wondering if it won't be harder to understand for most if there is a bunch of zeros in there?


There is also this edge case:
image

If the plan is to unify all the units it doesn't make much sense if part of the tooltip is in GW and the other parts are in MW.


I'm also just curious why you decided that the function should take an object as the argument. Nothing against it just curious about the reasoning here 🙂

@silkeholmebonnen
Copy link
Contributor Author

I'm also just curious why you decided that the function should take an object as the argument. Nothing against it just curious about the reasoning here 🙂

I did that so that both the total and the numberDigits parameters could be optional, so that you can specify which parameter you want to assign to which value when using it.

@silkeholmebonnen
Copy link
Contributor Author

Hmm, that's a lot of decimals in some places. Which might be fine information wise but have we checked that it won't break the UI on smaller devices in particular?

Yes, we should check this. I haven't done that yet.

And I'm wondering if it won't be harder to understand for most if there is a bunch of zeros in there?

I guess that based on the feedback that we have gotten, the assumption is that it easier to compare two numbers if they are using the same unit, than comparing two numbers that use different units. And if there is a bunch of zeros then it is also easier to see that this number is really small compared to the total, which might be fine I think

@silkeholmebonnen
Copy link
Contributor Author

If the plan is to unify all the units it doesn't make much sense if part of the tooltip is in GW and the other parts are in MW.

I think that is fine. I don't think the plan is to unify all the units, just to compare apples with apples, if that makes sense:)

@silkeholmebonnen
Copy link
Contributor Author

I just found this edge case, where the installed capacity is 0 so the value will be formatted by itself, since there is nothing to compare against. But in this case do you think we should then format the total (installed capacity) against the actual value, so that it would be 849 MW / 0 MW? Or is it not that important since the total is 0? It would require some logic to make it 849 MW / 0 MW, so do you think it is worth it?

Screenshot 2024-07-25 at 12 07 28

@Alportan
Copy link
Contributor

Alportan commented Jul 25, 2024

But in this case do you think we should then format the total (installed capacity) against the actual value, so that it would be 849 MW / 0 MW? Or is it not that important since the total is 0? It would require some logic to make it 849 MW / 0 MW, so do you think it is worth it?

I would say that for this edge case it's not really worth it to invest more effort for custom logic.

Where I do see some value though is, in case the capacity is not reported (I assume that's why it's 0) we should somehow explain why, but this is more of a UX task and unrelated to this PR. 😅 Same thing in case the reported capacity is lower than production.

@silkeholmebonnen
Copy link
Contributor Author

@VIKTORVAV99 and @tonypls, I just want to make sure that you did not forget about this PR 😄

@tonypls
Copy link
Collaborator

tonypls commented Aug 6, 2024

An edge case but in the example on Lanzarote when there's no capacity it shows as W when I would expect it to match the MW from the preceeding unit

image

@silkeholmebonnen
Copy link
Contributor Author

An edge case but in the example on Lanzarote when there's no capacity it shows as W when I would expect it to match the MW from the preceeding unit

We already discussed this further up ☝️ and decided that this edge case wasn't worth the extra logic that it would require. Do you think it is worth it?

@silkeholmebonnen
Copy link
Contributor Author

@tonypls Can I get this reviewed 🙏

@tonypls
Copy link
Collaborator

tonypls commented Aug 19, 2024

/review

Copy link
Contributor

PR Reviewer Guide 🔍

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Key issues to review

Typo in Parameter
The parameter name paramerters in the format function should be corrected to parameters for clarity and to avoid potential confusion.

Redundant Code
The check value == undefined is redundant because Number.isNaN(value) will already handle cases where value is undefined. Consider simplifying the condition.

Copy link
Collaborator

@tonypls tonypls left a comment

Choose a reason for hiding this comment

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

Looks good to me! While reviewing and I had context I decided to add in the check to show a "?" if the tooltip capacity is missing. Please review my code, merge if you're happy or @ me if I need to improve it!

@silkeholmebonnen
Copy link
Contributor Author

Your changes looked good to me. I made some small changes based on Githubs review:)

@silkeholmebonnen silkeholmebonnen enabled auto-merge (squash) August 20, 2024 13:11
@silkeholmebonnen silkeholmebonnen merged commit c0e51aa into master Aug 20, 2024
21 checks passed
@silkeholmebonnen silkeholmebonnen deleted the silkebonnen/avo-255-unify-unit-presentation-in-tool-tips branch August 20, 2024 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants