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

Ticks around binary prefixes? #177

Open
runarberg opened this issue May 6, 2019 · 4 comments
Open

Ticks around binary prefixes? #177

runarberg opened this issue May 6, 2019 · 4 comments

Comments

@runarberg
Copy link

When I’m plotting bits (or more likely bytes) it would be nice if I could arrange the ticks on the round binary prefix values, e.g. ["0.5 GiB", "1.0 GiB", "1.5 GiB", "2.0 GiB"] rather then on the SI prefix values.

This will be especially nice if d3/d3-format#33 goes through since .tickFormat(".2B") (where B indicated binary prefix) would create really ugly ticks.

@mbostock
Copy link
Member

mbostock commented Sep 2, 2019

d3.ticks (which is the basis of most scale.ticks implementations) is based on powers of ten, so I’m not sure if there’s a clean way to change the tick generation strategy. Though of course you can pass whatever values you want I axis.tickValues. Presumably the first thing we’d want is a standalone implementation of tick generation, in the style of d3.ticks but for binary prefix values. That work would happen in d3-array. Maybe call it d3.ticksBinary?

@mbostock
Copy link
Member

mbostock commented Sep 2, 2019

(It might be possible for scale.ticks to parse the tick format specifier, if it’s a string, and look for the B directive. The tick format specifier is typically passed to both scale.ticks and scale.tickFormat by the axis, though typically scale.ticks ignores the additional argument. But that could provide a very elegant way of switching both the tick generation method and the format with a single call to axis.ticks.)

@mbostock mbostock changed the title Ticks around binary prefixes Ticks around binary prefixes? Sep 2, 2019
@runarberg
Copy link
Author

@mbostock Thanks for the response. I’ll look into d3-array and see if I find time to open a PR with the changes necessary.

@nickofthyme
Copy link

nickofthyme commented Sep 20, 2021

Opened issue to add base to d3-array#ticks method. d3/d3-array#232. Not sure how this would impact tick nicing Changes to tickIncrement would apply these changes to nicing automatically, would just need to pass the base value.

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

No branches or pull requests

3 participants