qfes / rdeck

Deck.gl widget for R
https://qfes.github.io/rdeck
MIT License
97 stars 0 forks source link

Configurable `n_ticks` for discrete scales (excluding category) #81

Open anthonynorth opened 2 years ago

anthonynorth commented 2 years ago

Legend size is determined by the number of ticks. For discrete scales, number of ticks = number of breaks. This makes sense, but limits the number of breaks you can have for a discrete scale (assuming you want a legend).

Ticks need to align at the appropriate break between colours and ticks should be evenly spaced, so an arbitrary n_ticks isn't going to work. What we can do though, for a given n_ticks is find the closest number of ticks, such that the ticks are evenly spaced and align with legend breaks.

E.g. A threshold scale that has 9 breaks (including the limits) could have 9, 5, 3, 2 ticks. If asking for 6 ticks, the legend should render 5 (maybe with a warning), the colours on the legend should be half their usual height. legends

This would allow for arbitrarily complex discrete scales, where the legend is still useful.