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

views/home: Use ThreeSigFigs to display difficulty on homepage #1975

Merged
merged 4 commits into from
Jan 24, 2024

Conversation

matthawkins90
Copy link
Contributor

This is a quick fix for displaying the difficulty on the homepage. I just changed it to show the raw value instead of being divided by 1e6 and showing a "Mil" value.

I thought about trying to do something complicated and make a scaling value that switched formats if it became longer than 1e6, but I don't think it's worth the time investment it would take me.

@davecgh
Copy link
Member

davecgh commented Sep 25, 2023

I'll leave this one up to the dcrdata maintainers since it might be a controversial change without dynamic scaling. That said, I provided code in #1973 for dynamic scaling.

@matthawkins90
Copy link
Contributor Author

If dynamic scaling is important, I think I would like to get some feedback about how it should be displayed. Difficulty is unitless, so it just needs some kind of easy-to-interpret "scaling" suffix.

1234 = 1.23 k? 1.23e3? 1,234?
10000 = 10 k? 1e4? 10,000?
100000 = 100 k? 1e5? 100,000?
1000000 = 1 Mil? 1 M? 1.00M? 1e6? 1,000,000?

I don't think it's too hard, but I actually kinda like how it looks as 356,765, without decimals or scaling factors, so I didn't want to change it to something weird like 3.57e5 or 357 k

@xaur
Copy link

xaur commented Nov 19, 2023

1eX style is hard to read. If there are more than 3 digits it needs a thousand separator 356,765. Mil looks odd. IMO.

I vote for 999.00, 1.23 K, 10.00 K, 100.00 K, 1.00 M. Spelling out thousand, million, billion is also fine.

@buck54321
Copy link
Member

What about humanize.threeSigFigs?

@matthawkins90
Copy link
Contributor Author

Yeah, threeSigFigs is the easiest solution here. It already converts Floats into 3 digits with a possible "k", "M", or "B". The only downside is that it's formatted like 123k instead of 123 k, but all the other places using threeSigFigs suffer from the same problem. I could update it everywhere, but I think it was designed to look that way intentionally.

I'm not quite sure if updating homepage_controller.js actually did anything. I tried it multiple different ways, but everything looked fine regardless of what I did to homepage_controller.js. Please let me know if I need to revert that file.

@matthawkins90 matthawkins90 changed the title views/home: show raw difficulty int views/home: Use ThreeSigFigs to display difficulty on homepage Jan 16, 2024
@chappjc chappjc merged commit fa4fa14 into decred:master Jan 24, 2024
3 of 5 checks passed
@matthawkins90 matthawkins90 deleted the humanizehashrate branch January 24, 2024 05:51
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.

5 participants