We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I would like to propose an added option to allow returning ticks on a binary basis from the ticks method.
ticks
d3-array/src/ticks.js
Lines 5 to 35 in 6860b19
I imagine this could be an additional parameter like base such as...
base
export default function ticks(start, stop, count, base) {
Then this tickIncrement logic would be the only change
tickIncrement
Lines 37 to 44 in 6860b19
The changes would be something like...
-export function tickIncrement(start, stop, count) { +export function tickIncrement(start, stop, count, base = 10) { var step = (stop - start) / Math.max(0, count), - power = Math.floor(Math.log(step) / Math.LN10), + power = Math.floor(Math.log(step) / Math.log(base) + Number.EPSILON), - error = step / Math.pow(10, power); + error = step / Math.pow(base, power); return power >= 0 - ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) + ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(base, power) - : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1); + : -Math.pow(base, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1); }
Which would look something like...
domain: [0,1882] ticks: [0,256,512,768,1024,1280,1536,1792]
[0,1882]
[0,256,512,768,1024,1280,1536,1792]
domain: [0,1882] ticks: [0,200,400,600,800,1000,1200,1400,1600,1800]
[0,200,400,600,800,1000,1200,1400,1600,1800]
The text was updated successfully, but these errors were encountered:
If this is something that would be desired by the code owners I'd be happy to open a PR.
Sorry, something went wrong.
No response to PR for this feature
Successfully merging a pull request may close this issue.
I would like to propose an added option to allow returning ticks on a binary basis from the
ticks
method.d3-array/src/ticks.js
Lines 5 to 35 in 6860b19
I imagine this could be an additional parameter like
base
such as...Then this
tickIncrement
logic would be the only changed3-array/src/ticks.js
Lines 37 to 44 in 6860b19
The changes would be something like...
Which would look something like...
Base 2
domain:
[0,1882]
ticks:
[0,256,512,768,1024,1280,1536,1792]
Base 10 (default)
domain:
[0,1882]
ticks:
[0,200,400,600,800,1000,1200,1400,1600,1800]
The text was updated successfully, but these errors were encountered: