-
Notifications
You must be signed in to change notification settings - Fork 31
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
How to handle scaleSequential sales with interpolators? #73
Comments
Maybe the easiest thing to do is to detect whether the passed in range is a function and if so, don't set |
The syntax for this would be <LayerCake
zRange={() => interpolateRdGy} and internally in if (typeof defaultRange === 'function') {
scale.interpolator(defaultRange)
} else {
scale.range(defaultRange);
} I don't like that you would have to know to set zRange to a function in order to use an interpolator. I think I would rather get rid of the functionality that allows for range props to be functions since there isn't a great use case for that – just seemed like a possible option for down the road... |
This could be a better way to do it. Set an interpolator on the scale itself <LayerCake
zScale={scaleSequential(interpolateRdGy)}
...or
zScale={scaleSequential().interpolator(interpolateRdGy)} And then in layercake, only override the range if there is no scale interpolator function, or if there is one, that is the default identity function. This would allow the user to pass in a custom if (!scale.interpolator || (typeof scale.interpolator === 'function' && scale.interpolator().name.startsWith('identity'))) {
scale.range(defaultRange);
} Need to add documentation explaining that Open to any thoughts! |
This is added in v7.0 |
By default, LayerCake sets a range for each of the scales. This means that you shouldn't set ranges using the d3 shorthand
xScale={scaleBand([0, 100])}
but instead set these two props separatelyThis works fine except for color scales that need to be set via an interpolator method like this as described by d3-scale-chromatic:
This could be solved by adding
xInterpolator
,yInterpolator
,zInterpolator
andrInterpolator
props. Maybe that's too many props?The text was updated successfully, but these errors were encountered: