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

Max/Min length padding #43

Closed
Akkuma opened this issue Jan 30, 2013 · 5 comments
Closed

Max/Min length padding #43

Akkuma opened this issue Jan 30, 2013 · 5 comments

Comments

@Akkuma
Copy link

Akkuma commented Jan 30, 2013

Currently there isn't anyway to easily pad a number. For instance if I want my percentages to be at least 3 numbers, so that they are all roughly the same length, there isn't a way to do that easily. '0.0%' will result in xx.x% and x.x%.

@baer
Copy link
Contributor

baer commented Nov 15, 2013

Is this what you're trying to do? Appending more 0's will pad a number.

numeral(12).format("$00.00")
-> "$12.00"
numeral(12).format("00.00%")
-> "1200.00%"

@Akkuma
Copy link
Author

Akkuma commented Nov 19, 2013

No, that is not what I'm trying to do at least if I can recall properly, considering the issue is 10 months old. What I may have been trying to do this:

numeral(.1).format('0.0%')
-> '10.0%'
numeral(.01).format('0.0%')
-> '1.0%'

What I want is the character count between those two to be exactly the same, ie 10.0% and 1.00%. It helps make displaying them in a list look much cleaner and consistent. If you add an extra 0 it'll differ the two results. Obviously

@baer
Copy link
Contributor

baer commented Nov 19, 2013

I don't think I've ever seen this used - are there other UIs have you seen that pad numbers in this way?

@Akkuma
Copy link
Author

Akkuma commented Nov 19, 2013

Yes, I have seen UIs do this that don't want a zig zag look on their tables. http://josscrowcroft.github.io/accounting.js/ supports something like this via formatColumn, but chooses to implement it in a different fashion.

@adamwdraper
Copy link
Owner

Done

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

No branches or pull requests

3 participants