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 <mbostock@gmail.com>
Missing semi colon! Co-authored-by: Mike Bostock <mbostock@gmail.com>
Safe to use arrow function in unit tests Co-authored-by: Mike Bostock <mbostock@gmail.com>
Clear tickSizeInner and tickSizeOuter when setting tickSizeFunction Co-authored-by: Mike Bostock <mbostock@gmail.com>
|
Thanks for the comments @mbostock , committed all those suggestions |
|
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 <fil@rezo.net>
Updated DOCS as additional parameters now passed Co-authored-by: Philippe Rivière <fil@rezo.net>
|
@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! |
curran
left a comment
There was a problem hiding this comment.
Looks like a nice change to me!
|
@mbostock This looks like a great PR. Any way we can help get this accepted? |

