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

Use minus sign instead of hyphen-minus by default? #62

Closed
lucasdinonolte opened this issue Aug 9, 2018 · 3 comments · Fixed by #103
Closed

Use minus sign instead of hyphen-minus by default? #62

lucasdinonolte opened this issue Aug 9, 2018 · 3 comments · Fixed by #103

Comments

@lucasdinonolte
Copy link

Hi there,

I really like how your library supports a lot of locales for formatting numbers.

I was wondering if there was a way to use the correct minus sign (instead of the hyphen character) for negative numbers? If not, I’d like to suggest this as an enhancement.

A bit of background: A hyphen is usually shorter than a minus and is aligned with the lowercase letters of a font (as it is used to break words across lines). A minus sign is longer (in most cases it’ll have the width of the plus sign) and is vertically aligned slightly higher (it is aligned with the figures, which in most fonts used in websites have the height of uppercase numbers). See the attached image for a comparison of plus, minus and hyphen character.

210px-plus_minus_hyphen-minus svg

Cheers and keep up the good work 🎉

@kirkpsmith
Copy link

I came here through Altair->vega-lite->vega, asking the same question. Some more details from my post which may help:

When displaying negative numbers, use a minus sign (unicode 2212) instead of a hyphen -. There could be an option (like this one in matplotlib) to specify either option (but defaulting to the minus sign would be optimal).

In IDLE, you can see the difference between a true minus sign and a hyphen with this:
print(u'f\u2212f\nf\u002Df')
or
print(u'f\u2212f\nf-f')

Reference: Unicode for "hyphens"

@mbostock
Copy link
Member

(This post was cross-posted to the Observable forum.)

D3 did use the minus sign originally, but people complained about that, too (e.g., #595), primarily because there was an expectation that d3.format would use the same symbol as JavaScript’s number.toString. The minus sign was thus replaced with hyphen-minus in 2.10.0 (da3131c, #756).

I’m somewhat ambivalent. Both are technically correct. I’m aware that hyphen-minus is a compromise from a time where good typesetting was largely impractical for computers. As I commented on the linked issue, I don’t think it’s reasonable to expect d3.format to be compatible with JavaScript’s number coercion, since the goal of d3.format is to format numbers for human consumption instead of machines.

At any rate, we should at least allow you to override the minus sign in the locale, and perhaps it is worth reverting the adoption of hyphen-minus.

@mbostock
Copy link
Member

mbostock commented Sep 5, 2019

This is now available as an opt-in by specifying the locale’s minus property. And I’m considering making the minus sign the default (again) in the next major version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants