-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fix Usage percentage display #941
base: main
Are you sure you want to change the base?
Fix Usage percentage display #941
Conversation
@@ -157,8 +157,15 @@ const renderChromiumUsage: CellRenderer = ( | |||
_options, | |||
) => { | |||
if (feature.usage?.chromium?.daily && feature.usage.chromium.daily > 0) { | |||
// Format to display percentage with single decimal e.g. 0.8371 -> 83.7%. | |||
return html`${(feature.usage.chromium.daily * 100).toFixed(1)}%`; |
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.
Apologies for my earlier confusing comment internally. It is still a ratio between 0 and 1 from the backend. I meant to say the presentation layer here should present a percentage at most 100%. (whereas right now, we see values way above 100%). Once we fix the data upstream, the ratios will go back to being between 0 and 1 (and we can continue with the existing logic to make it a percentage).
return html`${(feature.usage.chromium.daily * 100).toFixed(1)}%`; | ||
// If the feature has some usage, but the usage is less than 0.1%, | ||
// display it that way. | ||
if (feature.usage.chromium.daily < 0.01) { |
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 do like this logic for very small numbers. Can you adjust it according to my comment above about how the number is indeed a ratio between 0 and 1.
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.
For both the regular case and the less than .1% case, we should have a hover over text that shows the precise number. This will help since we are truncating the values to a low number of decimal points.
Also, sorry again for the confusing comment internally.
Chromium usage is currently being displayed with inflated numbers (x100). This change updates the usage display to fix this bug.
Additionally, 0% usage values are explicitly displayed as "0.0%" rather than "N/A", and features with very small but non-zero usage are displayed as "<0.1%".