`scalePow` evenly spaced ticks?
vincerubinetti opened this issue · comments
Looking at the code and experimenting, it seems like scalePow
generates ticks in the same was as scaleLinear
. I think it'd be cool if it could generate evenly (after the application of the power) spaced ticks similar to how scaleLog
does.
I'm not exactly sure what this would look like at the moment, but I feel like it should be possible for scalePow
if it's possible for scaleLog
.
I could do something like this:
const min = 0;
const max = 100;
const power = 2;
const steps = 10;
const scale = d3.scalePow().domain([min, max]).range([min, max]).exponent(power);
const ticks = d3.range(scale.range()[0], scale.range()[1], steps).map((v) => scale.invert(v));
// or
const ticks = d3.ticks(scale.range()[0], scale.range()[1], steps).map((v) => scale.invert(v));
But I believe in the linear and log versions, there is more "magic" happening behind the scenes to make it look nice?
Actually it looks like d3-array has a ticks method that does some magic, but I'm still not sure integrating it into my example above is as good as linear/log's built-in ticking. Moreover, maybe this should be added regardless for convenience, so I don't have to do any of the work above.