plouc / nivo

nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries
https://nivo.rocks
MIT License
13.19k stars 1.03k forks source link

Axis tick count #138

Closed tj closed 6 years ago

tj commented 6 years ago

First of all thanks for the awesome project!

I was wondering is it possible to set the axis tick count? This way unknown series sizes should still scale reasonably well. Right now if you plot say weeks in a year you'll have a ton of overlapping labels.

Happy to send a pull-request as well!

cheers

plouc commented 6 years ago

@tj, it's possible for y axes, because they use a linear scale, however if you use dates based axis (quite common) or other kind of linear ones, you won't be able to set the tick count, because for now x axis is forced to scaleBand() which does not support this :/ I've tried to make it more versatile (see this), but I'd like to add it more progressively. In order to support this, the way scales are computed for each charts must be completely changed.

simonThiele commented 6 years ago

Currently, I use the format method of the axis configuration to achieve this in some cases:

axisBottom={{
    format: tick => (isTickWhichShouldBeHidden(tick) ? '' : tick)
    ...
}}

This avoids that the tick label is rendered at least. Not a real solution but it helps out in some cases.

plouc commented 6 years ago

This now available, see http://nivo.rocks/guides/axes

uclanate commented 6 years ago

Hi! I was wondering if setting the tickValues property also sets the domain of the x-axis? I have a scatter plot with data points clustered around large values (all >5k) and the minimum value is stuck at 0, so all the data is getting squished over to the right. If tickValues doesn't set the domain, what option does? I've tried passing in min, minValue, and domain to xScale and bottomAxis. Thanks so much for the help!!!