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

show always same number of decimal digits - even if "0" #10298

Open
hpvd opened this issue Jul 13, 2016 · 6 comments
Open

show always same number of decimal digits - even if "0" #10298

hpvd opened this issue Jul 13, 2016 · 6 comments
Labels
c: Consistent Reports & Analytics UX For bugs and features that make Analytics reporting UI behave more consistently. c: Usability For issues that let users achieve a defined goal more effectively or efficiently. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement.

Comments

@hpvd
Copy link

hpvd commented Jul 13, 2016

Show always same number of decimal digits (123.X) - even if "0"
otherways having no decimal digits on may think these values are rounded in another way...

hmm thought this was already solved some time ago?

Please see attachements

2016-07-13_10h28_27

2016-07-13_10h31_14

@tsteur
Copy link
Member

tsteur commented Jul 14, 2016

👍

@tsteur
Copy link
Member

tsteur commented Jul 14, 2016

this visualization may use a custom template so it might not have been solved there, just a guess

@mattab mattab added this to the 2.16.x (LTS) milestone Jul 14, 2016
@mattab mattab added Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. c: Usability For issues that let users achieve a defined goal more effectively or efficiently. labels Jul 14, 2016
@hpvd
Copy link
Author

hpvd commented Jul 15, 2016

looking again at the screenshots above, just found another tiny issues:
alignment broken in movers and shakers widget #10308

@mattab mattab modified the milestones: 3.0.0, 2.16.x (LTS) Jul 18, 2016
@obax
Copy link

obax commented Oct 4, 2017

I can make this quick fix. Would you assign this to me?

@mattab
Copy link
Member

mattab commented Oct 4, 2017

Hi @obax we don't assign issues, you can just create a Pull Request and reference this one 👍

@Morerice
Copy link
Contributor

In NumberFormatter::formatNumberWithPattern() there is this snippet in the final parts of the function, which ensures that the number does at least have the minimum number of fraction digits:

if ($minimumFractionDigits < $maximumFractionDigits) {
    // Strip any trailing zeroes.
    $minorDigits = rtrim($minorDigits, '0');
    if (strlen($minorDigits) < $minimumFractionDigits) {
        // Now there are too few digits, re-add trailing zeroes
        // until the desired length is reached.
        $neededZeroes = $minimumFractionDigits - strlen($minorDigits);
        $minorDigits .= str_repeat('0', $neededZeroes);
    }
}

Currently, if the minimum and maximum digits are equal, this is not executed and the value is rounded based on the maximum using the round() function.

The special case arises when the round() function has a whole number as its first parameter because this function does not add the decimal points. I'm guessing this was known when the formatter was developed because of this test in NumberFormatterTest: ('en', -50, 3, 3, '-50%').

Imo if the minimum = maximum it implies that the decimal point accuracy should be exactly as the number provided: ('en', -50, 3, 3, '-50.000%'). Would you agree with this?

@mattab mattab added the c: Consistent Reports & Analytics UX For bugs and features that make Analytics reporting UI behave more consistently. label Dec 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: Consistent Reports & Analytics UX For bugs and features that make Analytics reporting UI behave more consistently. c: Usability For issues that let users achieve a defined goal more effectively or efficiently. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement.
Projects
None yet
Development

No branches or pull requests

5 participants