-
Notifications
You must be signed in to change notification settings - Fork 107
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
axis.tickSize accepts a function #84
base: main
Are you sure you want to change the base?
Conversation
IPWright83
commented
Apr 6, 2022
- axis.tickSize accepts a function to allow changing the tickSize dynamically on a per tick basis - resolves #Ticks with varying size #74
* axis.tickSize accepts a function to allow changing the tickSize dynamically on a per tick basis
Pass function rather than manually calling Co-authored-by: Mike Bostock <[email protected]>
Missing semi colon! Co-authored-by: Mike Bostock <[email protected]>
Safe to use arrow function in unit tests Co-authored-by: Mike Bostock <[email protected]>
Clear tickSizeInner and tickSizeOuter when setting tickSizeFunction Co-authored-by: Mike Bostock <[email protected]>
Thanks for the comments @mbostock , committed all those suggestions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very useful! A few nits below (the nodes and this are passed as a consequence of a3e89d2).
What do you think about positioning the tick labels relatively to the ticks? Currently if using the function, the ticks "crash" into the axis, and I'm not sure how to fix that. Should we not also allow tickPadding to be a function, and set it to be the result of the tickSize function + a constant padding (unless it's already been set)? You can build on the demo notebook by forking it: To update the build, just run It would be great to add various examples making use the new feature. |
Make the snapshot readable Co-authored-by: Philippe Rivière <[email protected]>
Updated DOCS as additional parameters now passed Co-authored-by: Philippe Rivière <[email protected]>
@Fil thanks, I think you'd mentioned on Slack how to setup an Observable but I hadn't had much time. Decided I could just whip this PR together last night off the cuff. Yeah I can certainly add the example that I'm trying to build. I think you're right about |
Sorry, taken me a little while to get back to this. I've not added I've forked your example and add my use case in there (just showing major tick labels) https://observablehq.com/@ipwright83/d3-axis-ticksize-function-84 and thought of a crazy use case where you might want to move "longer labels" to prevent overlap. |
Sorry to message you direct @mbostock, but would love to be able to use this if possible without maintaining a fork. Is there anything you'd like to change to get this in? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a nice change to me!
@mbostock This looks like a great PR. Any way we can help get this accepted? |